diff options
-rw-r--r-- | drivers/extcon/extcon-max77693.c | 37 | ||||
-rw-r--r-- | include/linux/mfd/max77693.h | 2 |
2 files changed, 36 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 | ||
34 | enum max77693_muic_adc_debounce_time { | 35 | enum 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 | ||
924 | static 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 | |||
915 | static int max77693_muic_probe(struct platform_device *pdev) | 932 | static 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 | ||
diff --git a/include/linux/mfd/max77693.h b/include/linux/mfd/max77693.h index fe03b2d35d4f..9aa9c203f28b 100644 --- a/include/linux/mfd/max77693.h +++ b/include/linux/mfd/max77693.h | |||
@@ -38,6 +38,8 @@ struct max77693_reg_data { | |||
38 | struct max77693_muic_platform_data { | 38 | struct max77693_muic_platform_data { |
39 | struct max77693_reg_data *init_data; | 39 | struct max77693_reg_data *init_data; |
40 | int num_init_data; | 40 | int num_init_data; |
41 | |||
42 | int detcable_delay_ms; | ||
41 | }; | 43 | }; |
42 | 44 | ||
43 | struct max77693_platform_data { | 45 | struct max77693_platform_data { |