diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2013-02-13 01:10:00 -0500 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-02-13 17:54:49 -0500 |
commit | af5eb1a13273447c5708cd5425696f3b6f79dd9b (patch) | |
tree | d32eb0d7ae1197eafd200505bcfdec6229665bc0 /drivers/extcon | |
parent | 685dc9a7dbfede28cc4a0fe4e65804194ec04fa5 (diff) |
extcon: max8997: Use workqueue to check cable state after completing boot of platform
This patch use delayed workqueue to check cable state after a certain
time. If extcon-max8997 driver check cable state during booting of
platform, this couldn't send the correct notification of cable state
to extcon consumer. Alwasys, this driver should check cable state
after the completion of platform initialization
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-max8997.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 349f65f6a4a4..e636d950ad6c 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/irqdomain.h> | 29 | #include <linux/irqdomain.h> |
30 | 30 | ||
31 | #define DEV_NAME "max8997-muic" | 31 | #define DEV_NAME "max8997-muic" |
32 | #define DELAY_MS_DEFAULT 20000 /* unit: millisecond */ | ||
32 | 33 | ||
33 | enum max8997_muic_adc_debounce_time { | 34 | enum max8997_muic_adc_debounce_time { |
34 | ADC_DEBOUNCE_TIME_0_5MS = 0, /* 0.5ms */ | 35 | ADC_DEBOUNCE_TIME_0_5MS = 0, /* 0.5ms */ |
@@ -129,6 +130,14 @@ struct max8997_muic_info { | |||
129 | enum max8997_muic_charger_type pre_charger_type; | 130 | enum max8997_muic_charger_type pre_charger_type; |
130 | 131 | ||
131 | /* | 132 | /* |
133 | * Use delayed workqueue to detect cable state and then | ||
134 | * notify cable state to notifiee/platform through uevent. | ||
135 | * After completing the booting of platform, the extcon provider | ||
136 | * driver should notify cable state to upper layer. | ||
137 | */ | ||
138 | struct delayed_work wq_detcable; | ||
139 | |||
140 | /* | ||
132 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB | 141 | * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB |
133 | * h/w path of COMP2/COMN1 on CONTROL1 register. | 142 | * h/w path of COMP2/COMN1 on CONTROL1 register. |
134 | */ | 143 | */ |
@@ -629,11 +638,23 @@ static int max8997_muic_detect_dev(struct max8997_muic_info *info) | |||
629 | return 0; | 638 | return 0; |
630 | } | 639 | } |
631 | 640 | ||
641 | static void max8997_muic_detect_cable_wq(struct work_struct *work) | ||
642 | { | ||
643 | struct max8997_muic_info *info = container_of(to_delayed_work(work), | ||
644 | struct max8997_muic_info, wq_detcable); | ||
645 | int ret; | ||
646 | |||
647 | ret = max8997_muic_detect_dev(info); | ||
648 | if (ret < 0) | ||
649 | pr_err("failed to detect cable type\n"); | ||
650 | } | ||
651 | |||
632 | static int max8997_muic_probe(struct platform_device *pdev) | 652 | static int max8997_muic_probe(struct platform_device *pdev) |
633 | { | 653 | { |
634 | struct max8997_dev *max8997 = dev_get_drvdata(pdev->dev.parent); | 654 | struct max8997_dev *max8997 = dev_get_drvdata(pdev->dev.parent); |
635 | struct max8997_platform_data *pdata = dev_get_platdata(max8997->dev); | 655 | struct max8997_platform_data *pdata = dev_get_platdata(max8997->dev); |
636 | struct max8997_muic_info *info; | 656 | struct max8997_muic_info *info; |
657 | int delay_jiffies; | ||
637 | int ret, i; | 658 | int ret, i; |
638 | 659 | ||
639 | info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), | 660 | info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), |
@@ -721,17 +742,23 @@ static int max8997_muic_probe(struct platform_device *pdev) | |||
721 | /* Set ADC debounce time */ | 742 | /* Set ADC debounce time */ |
722 | max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); | 743 | max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); |
723 | 744 | ||
724 | /* Initial device detection */ | 745 | /* |
725 | ret = max8997_muic_detect_dev(info); | 746 | * Detect accessory after completing the initialization of platform |
726 | if (ret < 0) { | 747 | * |
727 | dev_err(&pdev->dev, "failed to detect cable type\n"); | 748 | * - Use delayed workqueue to detect cable state and then |
728 | goto err_extcon; | 749 | * notify cable state to notifiee/platform through uevent. |
729 | } | 750 | * After completing the booting of platform, the extcon provider |
751 | * driver should notify cable state to upper layer. | ||
752 | */ | ||
753 | INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq); | ||
754 | if (pdata->muic_pdata->detcable_delay_ms) | ||
755 | delay_jiffies = msecs_to_jiffies(pdata->muic_pdata->detcable_delay_ms); | ||
756 | else | ||
757 | delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT); | ||
758 | schedule_delayed_work(&info->wq_detcable, delay_jiffies); | ||
730 | 759 | ||
731 | return ret; | 760 | return 0; |
732 | 761 | ||
733 | err_extcon: | ||
734 | extcon_dev_unregister(info->edev); | ||
735 | err_irq: | 762 | err_irq: |
736 | while (--i >= 0) | 763 | while (--i >= 0) |
737 | free_irq(muic_irqs[i].virq, info); | 764 | free_irq(muic_irqs[i].virq, info); |