diff options
| -rw-r--r-- | drivers/extcon/extcon-max8997.c | 42 | ||||
| -rw-r--r-- | include/linux/mfd/max8997-private.h | 7 |
2 files changed, 49 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 | ||
| 33 | enum 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 | |||
| 33 | struct max8997_muic_irq { | 40 | struct 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 | */ | ||
| 109 | static 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 | ||
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h index 010173a92274..cd37a92ccba9 100644 --- a/include/linux/mfd/max8997-private.h +++ b/include/linux/mfd/max8997-private.h | |||
| @@ -251,6 +251,13 @@ enum max8997_muic_reg { | |||
| 251 | #define CONTROL2_USBCPINT_MASK (0x1 << CONTROL2_USBCPINT_SHIFT) | 251 | #define CONTROL2_USBCPINT_MASK (0x1 << CONTROL2_USBCPINT_SHIFT) |
| 252 | #define CONTROL2_RCPS_MASK (0x1 << CONTROL2_RCPS_SHIFT) | 252 | #define CONTROL2_RCPS_MASK (0x1 << CONTROL2_RCPS_SHIFT) |
| 253 | 253 | ||
| 254 | #define CONTROL3_JIGSET_SHIFT (0) | ||
| 255 | #define CONTROL3_BTLDSET_SHIFT (2) | ||
| 256 | #define CONTROL3_ADCDBSET_SHIFT (4) | ||
| 257 | #define CONTROL3_JIGSET_MASK (0x3 << CONTROL3_JIGSET_SHIFT) | ||
| 258 | #define CONTROL3_BTLDSET_MASK (0x3 << CONTROL3_BTLDSET_SHIFT) | ||
| 259 | #define CONTROL3_ADCDBSET_MASK (0x3 << CONTROL3_ADCDBSET_SHIFT) | ||
| 260 | |||
| 254 | #define MAX8997_ADC_GROUND 0x00 | 261 | #define MAX8997_ADC_GROUND 0x00 |
| 255 | #define MAX8997_ADC_MHL 0x01 | 262 | #define MAX8997_ADC_MHL 0x01 |
| 256 | #define MAX8997_ADC_JIG_USB_1 0x18 | 263 | #define MAX8997_ADC_JIG_USB_1 0x18 |
