aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-max8997.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 8739b50c2b36..3206daaf8e08 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -30,6 +30,13 @@
30 30
31#define DEV_NAME "max8997-muic" 31#define DEV_NAME "max8997-muic"
32 32
33enum max8997_muic_adc_debounce_time {
34 ADC_DEBOUNCE_TIME_0_5MS = 0, /* 0.5ms */
35 ADC_DEBOUNCE_TIME_10MS, /* 10ms */
36 ADC_DEBOUNCE_TIME_25MS, /* 25ms */
37 ADC_DEBOUNCE_TIME_38_62MS, /* 38.62ms */
38};
39
33struct max8997_muic_irq { 40struct max8997_muic_irq {
34 unsigned int irq; 41 unsigned int irq;
35 const char *name; 42 const char *name;
@@ -95,6 +102,38 @@ static const char *max8997_extcon_cable[] = {
95}; 102};
96 103
97/* 104/*
105 * max8997_muic_set_debounce_time - Set the debounce time of ADC
106 * @info: the instance including private data of max8997 MUIC
107 * @time: the debounce time of ADC
108 */
109static int max8997_muic_set_debounce_time(struct max8997_muic_info *info,
110 enum max8997_muic_adc_debounce_time time)
111{
112 int ret;
113
114 switch (time) {
115 case ADC_DEBOUNCE_TIME_0_5MS:
116 case ADC_DEBOUNCE_TIME_10MS:
117 case ADC_DEBOUNCE_TIME_25MS:
118 case ADC_DEBOUNCE_TIME_38_62MS:
119 ret = max8997_update_reg(info->muic,
120 MAX8997_MUIC_REG_CONTROL3,
121 time << CONTROL3_ADCDBSET_SHIFT,
122 CONTROL3_ADCDBSET_MASK);
123 if (ret) {
124 dev_err(info->dev, "failed to set ADC debounce time\n");
125 return -EAGAIN;
126 }
127 break;
128 default:
129 dev_err(info->dev, "invalid ADC debounce time\n");
130 return -EINVAL;
131 }
132
133 return 0;
134};
135
136/*
98 * max8997_muic_set_path - Set hardware line according to attached cable 137 * max8997_muic_set_path - Set hardware line according to attached cable
99 * @info: the instance including private data of max8997 MUIC 138 * @info: the instance including private data of max8997 MUIC
100 * @value: the path according to attached cable 139 * @value: the path according to attached cable
@@ -507,6 +546,9 @@ static int max8997_muic_probe(struct platform_device *pdev)
507 } 546 }
508 } 547 }
509 548
549 /* Set ADC debounce time */
550 max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
551
510 /* Initial device detection */ 552 /* Initial device detection */
511 max8997_muic_detect_dev(info); 553 max8997_muic_detect_dev(info);
512 554