aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-max77693.c
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2012-12-25 23:10:11 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2013-01-15 01:42:15 -0500
commit297620fd1e14edf5fefa1736f873b9228336eee1 (patch)
tree2aaed8a7ce207853299a16cce680196e3e03e043 /drivers/extcon/extcon-max77693.c
parent39bf369e4ed321158eb8dc5031b4a9f2108ea614 (diff)
extcon: max77693: Check the state/type of cable after boot completed
This patch check the state/type of cable after completing the initialization of platform and notify platform of cable state/type through extcon. If extcon provider driver notify the state/type of cable before completing platform boot, this uevent is unused and ignored. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon/extcon-max77693.c')
-rw-r--r--drivers/extcon/extcon-max77693.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 07ea96bfd0cb..10f41f3d5be4 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -30,6 +30,7 @@
30#include <linux/irqdomain.h> 30#include <linux/irqdomain.h>
31 31
32#define DEV_NAME "max77693-muic" 32#define DEV_NAME "max77693-muic"
33#define DELAY_MS_DEFAULT 20000 /* unit: millisecond */
33 34
34enum max77693_muic_adc_debounce_time { 35enum max77693_muic_adc_debounce_time {
35 ADC_DEBOUNCE_TIME_5MS = 0, 36 ADC_DEBOUNCE_TIME_5MS = 0,
@@ -52,6 +53,14 @@ struct max77693_muic_info {
52 struct work_struct irq_work; 53 struct work_struct irq_work;
53 struct mutex mutex; 54 struct mutex mutex;
54 55
56 /*
57 * Use delayed workqueue to detect cable state and then
58 * notify cable state to notifiee/platform through uevent.
59 * After completing the booting of platform, the extcon provider
60 * driver should notify cable state to upper layer.
61 */
62 struct delayed_work wq_detcable;
63
55 /* Button of dock device */ 64 /* Button of dock device */
56 struct input_dev *dock; 65 struct input_dev *dock;
57}; 66};
@@ -912,13 +921,23 @@ static int max77693_muic_detect_accessory(struct max77693_muic_info *info)
912 return ret; 921 return ret;
913} 922}
914 923
924static void max77693_muic_detect_cable_wq(struct work_struct *work)
925{
926 struct max77693_muic_info *info = container_of(to_delayed_work(work),
927 struct max77693_muic_info, wq_detcable);
928
929 max77693_muic_detect_accessory(info);
930}
931
915static int max77693_muic_probe(struct platform_device *pdev) 932static int max77693_muic_probe(struct platform_device *pdev)
916{ 933{
917 struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent); 934 struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
918 struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev); 935 struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev);
919 struct max77693_muic_platform_data *muic_pdata = pdata->muic_data; 936 struct max77693_muic_platform_data *muic_pdata = pdata->muic_data;
920 struct max77693_muic_info *info; 937 struct max77693_muic_info *info;
921 int ret, i; 938 int delay_jiffies;
939 int ret;
940 int i;
922 u8 id; 941 u8 id;
923 942
924 info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info), 943 info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info),
@@ -1051,8 +1070,20 @@ static int max77693_muic_probe(struct platform_device *pdev)
1051 /* Set ADC debounce time */ 1070 /* Set ADC debounce time */
1052 max77693_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); 1071 max77693_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
1053 1072
1054 /* Detect accessory on boot */ 1073 /*
1055 max77693_muic_detect_accessory(info); 1074 * Detect accessory after completing the initialization of platform
1075 *
1076 * - Use delayed workqueue to detect cable state and then
1077 * notify cable state to notifiee/platform through uevent.
1078 * After completing the booting of platform, the extcon provider
1079 * driver should notify cable state to upper layer.
1080 */
1081 INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq);
1082 if (muic_pdata->detcable_delay_ms)
1083 delay_jiffies = msecs_to_jiffies(muic_pdata->detcable_delay_ms);
1084 else
1085 delay_jiffies = msecs_to_jiffies(DELAY_MS_DEFAULT);
1086 schedule_delayed_work(&info->wq_detcable, delay_jiffies);
1056 1087
1057 return ret; 1088 return ret;
1058 1089