diff options
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r-- | drivers/extcon/extcon-arizona.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index c17a41ff60ea..2ad0e4a35a23 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c | |||
@@ -53,6 +53,8 @@ struct arizona_extcon_info { | |||
53 | bool micd_reva; | 53 | bool micd_reva; |
54 | bool micd_clamp; | 54 | bool micd_clamp; |
55 | 55 | ||
56 | struct delayed_work hpdet_work; | ||
57 | |||
56 | bool hpdet_active; | 58 | bool hpdet_active; |
57 | 59 | ||
58 | int num_hpdet_res; | 60 | int num_hpdet_res; |
@@ -640,7 +642,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info) | |||
640 | dev_dbg(arizona->dev, "Starting identification via HPDET\n"); | 642 | dev_dbg(arizona->dev, "Starting identification via HPDET\n"); |
641 | 643 | ||
642 | /* Make sure we keep the device enabled during the measurement */ | 644 | /* Make sure we keep the device enabled during the measurement */ |
643 | pm_runtime_get(info->dev); | 645 | pm_runtime_get_sync(info->dev); |
644 | 646 | ||
645 | info->hpdet_active = true; | 647 | info->hpdet_active = true; |
646 | 648 | ||
@@ -813,6 +815,17 @@ handled: | |||
813 | return IRQ_HANDLED; | 815 | return IRQ_HANDLED; |
814 | } | 816 | } |
815 | 817 | ||
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 | |||
816 | static irqreturn_t arizona_jackdet(int irq, void *data) | 829 | static irqreturn_t arizona_jackdet(int irq, void *data) |
817 | { | 830 | { |
818 | struct arizona_extcon_info *info = data; | 831 | struct arizona_extcon_info *info = data; |
@@ -822,6 +835,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
822 | 835 | ||
823 | pm_runtime_get_sync(info->dev); | 836 | pm_runtime_get_sync(info->dev); |
824 | 837 | ||
838 | cancel_delayed_work_sync(&info->hpdet_work); | ||
839 | |||
825 | mutex_lock(&info->lock); | 840 | mutex_lock(&info->lock); |
826 | 841 | ||
827 | if (arizona->pdata.jd_gpio5) { | 842 | if (arizona->pdata.jd_gpio5) { |
@@ -857,7 +872,8 @@ static irqreturn_t arizona_jackdet(int irq, void *data) | |||
857 | 872 | ||
858 | arizona_start_mic(info); | 873 | arizona_start_mic(info); |
859 | } else { | 874 | } else { |
860 | arizona_start_hpdet_acc_id(info); | 875 | schedule_delayed_work(&info->hpdet_work, |
876 | msecs_to_jiffies(250)); | ||
861 | } | 877 | } |
862 | 878 | ||
863 | regmap_update_bits(arizona->regmap, | 879 | regmap_update_bits(arizona->regmap, |
@@ -927,6 +943,7 @@ static int arizona_extcon_probe(struct platform_device *pdev) | |||
927 | mutex_init(&info->lock); | 943 | mutex_init(&info->lock); |
928 | info->arizona = arizona; | 944 | info->arizona = arizona; |
929 | info->dev = &pdev->dev; | 945 | info->dev = &pdev->dev; |
946 | INIT_DELAYED_WORK(&info->hpdet_work, arizona_hpdet_work); | ||
930 | platform_set_drvdata(pdev, info); | 947 | platform_set_drvdata(pdev, info); |
931 | 948 | ||
932 | switch (arizona->type) { | 949 | switch (arizona->type) { |
@@ -1173,6 +1190,7 @@ static int arizona_extcon_remove(struct platform_device *pdev) | |||
1173 | arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info); | 1190 | arizona_free_irq(arizona, ARIZONA_IRQ_MICDET, info); |
1174 | arizona_free_irq(arizona, jack_irq_rise, info); | 1191 | arizona_free_irq(arizona, jack_irq_rise, info); |
1175 | arizona_free_irq(arizona, jack_irq_fall, info); | 1192 | arizona_free_irq(arizona, jack_irq_fall, info); |
1193 | cancel_delayed_work_sync(&info->hpdet_work); | ||
1176 | regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, | 1194 | regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, |
1177 | ARIZONA_JD1_ENA, 0); | 1195 | ARIZONA_JD1_ENA, 0); |
1178 | arizona_clk32k_disable(arizona); | 1196 | arizona_clk32k_disable(arizona); |