1 // SPDX-License-Identifier: GPL-2.0+
3 // extcon-max14577.c - MAX14577/77836 extcon driver to support MUIC
5 // Copyright (C) 2013,2014 Samsung Electronics
6 // Chanwoo Choi <cw00.choi@samsung.com>
7 // Krzysztof Kozlowski <krzk@kernel.org>
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/i2c.h>
12 #include <linux/interrupt.h>
13 #include <linux/platform_device.h>
14 #include <linux/mfd/max14577.h>
15 #include <linux/mfd/max14577-private.h>
16 #include <linux/extcon-provider.h>
18 #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
20 enum max14577_muic_adc_debounce_time
{
21 ADC_DEBOUNCE_TIME_5MS
= 0,
22 ADC_DEBOUNCE_TIME_10MS
,
23 ADC_DEBOUNCE_TIME_25MS
,
24 ADC_DEBOUNCE_TIME_38_62MS
,
27 enum max14577_muic_status
{
28 MAX14577_MUIC_STATUS1
= 0,
29 MAX14577_MUIC_STATUS2
= 1,
30 MAX14577_MUIC_STATUS_END
,
34 * struct max14577_muic_irq
35 * @irq: the index of irq list of MUIC device.
36 * @name: the name of irq.
37 * @virq: the virtual irq to use irq domain
39 struct max14577_muic_irq
{
45 static struct max14577_muic_irq max14577_muic_irqs
[] = {
46 { MAX14577_IRQ_INT1_ADC
, "muic-ADC" },
47 { MAX14577_IRQ_INT1_ADCLOW
, "muic-ADCLOW" },
48 { MAX14577_IRQ_INT1_ADCERR
, "muic-ADCError" },
49 { MAX14577_IRQ_INT2_CHGTYP
, "muic-CHGTYP" },
50 { MAX14577_IRQ_INT2_CHGDETRUN
, "muic-CHGDETRUN" },
51 { MAX14577_IRQ_INT2_DCDTMR
, "muic-DCDTMR" },
52 { MAX14577_IRQ_INT2_DBCHG
, "muic-DBCHG" },
53 { MAX14577_IRQ_INT2_VBVOLT
, "muic-VBVOLT" },
56 static struct max14577_muic_irq max77836_muic_irqs
[] = {
57 { MAX14577_IRQ_INT1_ADC
, "muic-ADC" },
58 { MAX14577_IRQ_INT1_ADCLOW
, "muic-ADCLOW" },
59 { MAX14577_IRQ_INT1_ADCERR
, "muic-ADCError" },
60 { MAX77836_IRQ_INT1_ADC1K
, "muic-ADC1K" },
61 { MAX14577_IRQ_INT2_CHGTYP
, "muic-CHGTYP" },
62 { MAX14577_IRQ_INT2_CHGDETRUN
, "muic-CHGDETRUN" },
63 { MAX14577_IRQ_INT2_DCDTMR
, "muic-DCDTMR" },
64 { MAX14577_IRQ_INT2_DBCHG
, "muic-DBCHG" },
65 { MAX14577_IRQ_INT2_VBVOLT
, "muic-VBVOLT" },
66 { MAX77836_IRQ_INT2_VIDRM
, "muic-VIDRM" },
69 struct max14577_muic_info
{
71 struct max14577
*max14577
;
72 struct extcon_dev
*edev
;
75 u8 status
[MAX14577_MUIC_STATUS_END
];
77 struct max14577_muic_irq
*muic_irqs
;
78 unsigned int muic_irqs_num
;
81 struct work_struct irq_work
;
85 * Use delayed workqueue to detect cable state and then
86 * notify cable state to notifiee/platform through uevent.
87 * After completing the booting of platform, the extcon provider
88 * driver should notify cable state to upper layer.
90 struct delayed_work wq_detcable
;
93 * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
94 * h/w path of COMP2/COMN1 on CONTROL1 register.
100 enum max14577_muic_cable_group
{
101 MAX14577_CABLE_GROUP_ADC
= 0,
102 MAX14577_CABLE_GROUP_CHG
,
105 /* Define supported accessory type */
106 enum max14577_muic_acc_type
{
107 MAX14577_MUIC_ADC_GROUND
= 0x0,
108 MAX14577_MUIC_ADC_SEND_END_BUTTON
,
109 MAX14577_MUIC_ADC_REMOTE_S1_BUTTON
,
110 MAX14577_MUIC_ADC_REMOTE_S2_BUTTON
,
111 MAX14577_MUIC_ADC_REMOTE_S3_BUTTON
,
112 MAX14577_MUIC_ADC_REMOTE_S4_BUTTON
,
113 MAX14577_MUIC_ADC_REMOTE_S5_BUTTON
,
114 MAX14577_MUIC_ADC_REMOTE_S6_BUTTON
,
115 MAX14577_MUIC_ADC_REMOTE_S7_BUTTON
,
116 MAX14577_MUIC_ADC_REMOTE_S8_BUTTON
,
117 MAX14577_MUIC_ADC_REMOTE_S9_BUTTON
,
118 MAX14577_MUIC_ADC_REMOTE_S10_BUTTON
,
119 MAX14577_MUIC_ADC_REMOTE_S11_BUTTON
,
120 MAX14577_MUIC_ADC_REMOTE_S12_BUTTON
,
121 MAX14577_MUIC_ADC_RESERVED_ACC_1
,
122 MAX14577_MUIC_ADC_RESERVED_ACC_2
,
123 MAX14577_MUIC_ADC_RESERVED_ACC_3
,
124 MAX14577_MUIC_ADC_RESERVED_ACC_4
,
125 MAX14577_MUIC_ADC_RESERVED_ACC_5
,
126 MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE2
,
127 MAX14577_MUIC_ADC_PHONE_POWERED_DEV
,
128 MAX14577_MUIC_ADC_TTY_CONVERTER
,
129 MAX14577_MUIC_ADC_UART_CABLE
,
130 MAX14577_MUIC_ADC_CEA936A_TYPE1_CHG
,
131 MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF
,
132 MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON
,
133 MAX14577_MUIC_ADC_AV_CABLE_NOLOAD
,
134 MAX14577_MUIC_ADC_CEA936A_TYPE2_CHG
,
135 MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF
,
136 MAX14577_MUIC_ADC_FACTORY_MODE_UART_ON
,
137 MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE1
, /* with Remote and Simple Ctrl */
138 MAX14577_MUIC_ADC_OPEN
,
141 static const unsigned int max14577_extcon_cable
[] = {
153 * max14577_muic_set_debounce_time - Set the debounce time of ADC
154 * @info: the instance including private data of max14577 MUIC
155 * @time: the debounce time of ADC
157 static int max14577_muic_set_debounce_time(struct max14577_muic_info
*info
,
158 enum max14577_muic_adc_debounce_time time
)
163 case ADC_DEBOUNCE_TIME_5MS
:
164 case ADC_DEBOUNCE_TIME_10MS
:
165 case ADC_DEBOUNCE_TIME_25MS
:
166 case ADC_DEBOUNCE_TIME_38_62MS
:
167 ret
= max14577_update_reg(info
->max14577
->regmap
,
168 MAX14577_MUIC_REG_CONTROL3
,
170 time
<< CTRL3_ADCDBSET_SHIFT
);
172 dev_err(info
->dev
, "failed to set ADC debounce time\n");
177 dev_err(info
->dev
, "invalid ADC debounce time\n");
185 * max14577_muic_set_path - Set hardware line according to attached cable
186 * @info: the instance including private data of max14577 MUIC
187 * @value: the path according to attached cable
188 * @attached: the state of cable (true:attached, false:detached)
190 * The max14577 MUIC device share outside H/W line among a varity of cables
191 * so, this function set internal path of H/W line according to the type of
194 static int max14577_muic_set_path(struct max14577_muic_info
*info
,
195 u8 val
, bool attached
)
200 /* Set open state to path before changing hw path */
201 ret
= max14577_update_reg(info
->max14577
->regmap
,
202 MAX14577_MUIC_REG_CONTROL1
,
203 CLEAR_IDBEN_MICEN_MASK
, CTRL1_SW_OPEN
);
205 dev_err(info
->dev
, "failed to update MUIC register\n");
212 ctrl1
= CTRL1_SW_OPEN
;
214 ret
= max14577_update_reg(info
->max14577
->regmap
,
215 MAX14577_MUIC_REG_CONTROL1
,
216 CLEAR_IDBEN_MICEN_MASK
, ctrl1
);
218 dev_err(info
->dev
, "failed to update MUIC register\n");
223 ctrl2
|= CTRL2_CPEN_MASK
; /* LowPwr=0, CPEn=1 */
225 ctrl2
|= CTRL2_LOWPWR_MASK
; /* LowPwr=1, CPEn=0 */
227 ret
= max14577_update_reg(info
->max14577
->regmap
,
228 MAX14577_REG_CONTROL2
,
229 CTRL2_LOWPWR_MASK
| CTRL2_CPEN_MASK
, ctrl2
);
231 dev_err(info
->dev
, "failed to update MUIC register\n");
236 "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n",
237 ctrl1
, ctrl2
, attached
? "attached" : "detached");
243 * max14577_muic_get_cable_type - Return cable type and check cable state
244 * @info: the instance including private data of max14577 MUIC
245 * @group: the path according to attached cable
246 * @attached: store cable state and return
248 * This function check the cable state either attached or detached,
249 * and then divide precise type of cable according to cable group.
250 * - max14577_CABLE_GROUP_ADC
251 * - max14577_CABLE_GROUP_CHG
253 static int max14577_muic_get_cable_type(struct max14577_muic_info
*info
,
254 enum max14577_muic_cable_group group
, bool *attached
)
261 case MAX14577_CABLE_GROUP_ADC
:
263 * Read ADC value to check cable type and decide cable state
264 * according to cable type
266 adc
= info
->status
[MAX14577_MUIC_STATUS1
] & STATUS1_ADC_MASK
;
267 adc
>>= STATUS1_ADC_SHIFT
;
270 * Check current cable state/cable type and store cable type
271 * (info->prev_cable_type) for handling cable when cable is
274 if (adc
== MAX14577_MUIC_ADC_OPEN
) {
277 cable_type
= info
->prev_cable_type
;
278 info
->prev_cable_type
= MAX14577_MUIC_ADC_OPEN
;
282 cable_type
= info
->prev_cable_type
= adc
;
285 case MAX14577_CABLE_GROUP_CHG
:
287 * Read charger type to check cable type and decide cable state
288 * according to type of charger cable.
290 chg_type
= info
->status
[MAX14577_MUIC_STATUS2
] &
292 chg_type
>>= STATUS2_CHGTYP_SHIFT
;
294 if (chg_type
== MAX14577_CHARGER_TYPE_NONE
) {
297 cable_type
= info
->prev_chg_type
;
298 info
->prev_chg_type
= MAX14577_CHARGER_TYPE_NONE
;
303 * Check current cable state/cable type and store cable
304 * type(info->prev_chg_type) for handling cable when
305 * charger cable is detached.
307 cable_type
= info
->prev_chg_type
= chg_type
;
312 dev_err(info
->dev
, "Unknown cable group (%d)\n", group
);
313 cable_type
= -EINVAL
;
320 static int max14577_muic_jig_handler(struct max14577_muic_info
*info
,
321 int cable_type
, bool attached
)
324 u8 path
= CTRL1_SW_OPEN
;
327 "external connector is %s (adc:0x%02x)\n",
328 attached
? "attached" : "detached", cable_type
);
330 switch (cable_type
) {
331 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF
: /* ADC_JIG_USB_OFF */
332 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON
: /* ADC_JIG_USB_ON */
336 case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF
: /* ADC_JIG_UART_OFF */
338 path
= CTRL1_SW_UART
;
341 dev_err(info
->dev
, "failed to detect %s jig cable\n",
342 attached
? "attached" : "detached");
346 ret
= max14577_muic_set_path(info
, path
, attached
);
350 extcon_set_state_sync(info
->edev
, EXTCON_JIG
, attached
);
355 static int max14577_muic_adc_handler(struct max14577_muic_info
*info
)
361 /* Check accessory state which is either detached or attached */
362 cable_type
= max14577_muic_get_cable_type(info
,
363 MAX14577_CABLE_GROUP_ADC
, &attached
);
366 "external connector is %s (adc:0x%02x, prev_adc:0x%x)\n",
367 attached
? "attached" : "detached", cable_type
,
368 info
->prev_cable_type
);
370 switch (cable_type
) {
371 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF
:
372 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON
:
373 case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF
:
375 ret
= max14577_muic_jig_handler(info
, cable_type
, attached
);
379 case MAX14577_MUIC_ADC_GROUND
:
380 case MAX14577_MUIC_ADC_SEND_END_BUTTON
:
381 case MAX14577_MUIC_ADC_REMOTE_S1_BUTTON
:
382 case MAX14577_MUIC_ADC_REMOTE_S2_BUTTON
:
383 case MAX14577_MUIC_ADC_REMOTE_S3_BUTTON
:
384 case MAX14577_MUIC_ADC_REMOTE_S4_BUTTON
:
385 case MAX14577_MUIC_ADC_REMOTE_S5_BUTTON
:
386 case MAX14577_MUIC_ADC_REMOTE_S6_BUTTON
:
387 case MAX14577_MUIC_ADC_REMOTE_S7_BUTTON
:
388 case MAX14577_MUIC_ADC_REMOTE_S8_BUTTON
:
389 case MAX14577_MUIC_ADC_REMOTE_S9_BUTTON
:
390 case MAX14577_MUIC_ADC_REMOTE_S10_BUTTON
:
391 case MAX14577_MUIC_ADC_REMOTE_S11_BUTTON
:
392 case MAX14577_MUIC_ADC_REMOTE_S12_BUTTON
:
393 case MAX14577_MUIC_ADC_RESERVED_ACC_1
:
394 case MAX14577_MUIC_ADC_RESERVED_ACC_2
:
395 case MAX14577_MUIC_ADC_RESERVED_ACC_3
:
396 case MAX14577_MUIC_ADC_RESERVED_ACC_4
:
397 case MAX14577_MUIC_ADC_RESERVED_ACC_5
:
398 case MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE2
:
399 case MAX14577_MUIC_ADC_PHONE_POWERED_DEV
:
400 case MAX14577_MUIC_ADC_TTY_CONVERTER
:
401 case MAX14577_MUIC_ADC_UART_CABLE
:
402 case MAX14577_MUIC_ADC_CEA936A_TYPE1_CHG
:
403 case MAX14577_MUIC_ADC_AV_CABLE_NOLOAD
:
404 case MAX14577_MUIC_ADC_CEA936A_TYPE2_CHG
:
405 case MAX14577_MUIC_ADC_FACTORY_MODE_UART_ON
:
406 case MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE1
:
408 * This accessory isn't used in general case if it is specially
409 * needed to detect additional accessory, should implement
410 * proper operation when this accessory is attached/detached.
413 "accessory is %s but it isn't used (adc:0x%x)\n",
414 attached
? "attached" : "detached", cable_type
);
418 "failed to detect %s accessory (adc:0x%x)\n",
419 attached
? "attached" : "detached", cable_type
);
426 static int max14577_muic_chg_handler(struct max14577_muic_info
*info
)
432 chg_type
= max14577_muic_get_cable_type(info
,
433 MAX14577_CABLE_GROUP_CHG
, &attached
);
436 "external connector is %s(chg_type:0x%x, prev_chg_type:0x%x)\n",
437 attached
? "attached" : "detached",
438 chg_type
, info
->prev_chg_type
);
441 case MAX14577_CHARGER_TYPE_USB
:
443 ret
= max14577_muic_set_path(info
, info
->path_usb
, attached
);
447 extcon_set_state_sync(info
->edev
, EXTCON_USB
, attached
);
448 extcon_set_state_sync(info
->edev
, EXTCON_CHG_USB_SDP
,
451 case MAX14577_CHARGER_TYPE_DEDICATED_CHG
:
452 extcon_set_state_sync(info
->edev
, EXTCON_CHG_USB_DCP
,
455 case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT
:
456 extcon_set_state_sync(info
->edev
, EXTCON_CHG_USB_CDP
,
459 case MAX14577_CHARGER_TYPE_SPECIAL_500MA
:
460 extcon_set_state_sync(info
->edev
, EXTCON_CHG_USB_SLOW
,
463 case MAX14577_CHARGER_TYPE_SPECIAL_1A
:
464 extcon_set_state_sync(info
->edev
, EXTCON_CHG_USB_FAST
,
467 case MAX14577_CHARGER_TYPE_NONE
:
468 case MAX14577_CHARGER_TYPE_DEAD_BATTERY
:
472 "failed to detect %s accessory (chg_type:0x%x)\n",
473 attached
? "attached" : "detached", chg_type
);
480 static void max14577_muic_irq_work(struct work_struct
*work
)
482 struct max14577_muic_info
*info
= container_of(work
,
483 struct max14577_muic_info
, irq_work
);
489 mutex_lock(&info
->mutex
);
491 ret
= max14577_bulk_read(info
->max14577
->regmap
,
492 MAX14577_MUIC_REG_STATUS1
, info
->status
, 2);
494 dev_err(info
->dev
, "failed to read MUIC register\n");
495 mutex_unlock(&info
->mutex
);
500 ret
= max14577_muic_adc_handler(info
);
501 info
->irq_adc
= false;
504 ret
= max14577_muic_chg_handler(info
);
505 info
->irq_chg
= false;
509 dev_err(info
->dev
, "failed to handle MUIC interrupt\n");
511 mutex_unlock(&info
->mutex
);
515 * Sets irq_adc or irq_chg in max14577_muic_info and returns 1.
516 * Returns 0 if irq_type does not match registered IRQ for this device type.
518 static int max14577_parse_irq(struct max14577_muic_info
*info
, int irq_type
)
521 case MAX14577_IRQ_INT1_ADC
:
522 case MAX14577_IRQ_INT1_ADCLOW
:
523 case MAX14577_IRQ_INT1_ADCERR
:
525 * Handle all of accessory except for
526 * type of charger accessory.
528 info
->irq_adc
= true;
530 case MAX14577_IRQ_INT2_CHGTYP
:
531 case MAX14577_IRQ_INT2_CHGDETRUN
:
532 case MAX14577_IRQ_INT2_DCDTMR
:
533 case MAX14577_IRQ_INT2_DBCHG
:
534 case MAX14577_IRQ_INT2_VBVOLT
:
535 /* Handle charger accessory */
536 info
->irq_chg
= true;
544 * Sets irq_adc or irq_chg in max14577_muic_info and returns 1.
545 * Returns 0 if irq_type does not match registered IRQ for this device type.
547 static int max77836_parse_irq(struct max14577_muic_info
*info
, int irq_type
)
549 /* First check common max14577 interrupts */
550 if (max14577_parse_irq(info
, irq_type
))
554 case MAX77836_IRQ_INT1_ADC1K
:
555 info
->irq_adc
= true;
557 case MAX77836_IRQ_INT2_VIDRM
:
558 /* Handle charger accessory */
559 info
->irq_chg
= true;
566 static irqreturn_t
max14577_muic_irq_handler(int irq
, void *data
)
568 struct max14577_muic_info
*info
= data
;
569 int i
, irq_type
= -1;
573 * We may be called multiple times for different nested IRQ-s.
574 * Including changes in INT1_ADC and INT2_CGHTYP at once.
575 * However we only need to know whether it was ADC, charger
576 * or both interrupts so decode IRQ and turn on proper flags.
578 for (i
= 0; i
< info
->muic_irqs_num
; i
++)
579 if (irq
== info
->muic_irqs
[i
].virq
)
580 irq_type
= info
->muic_irqs
[i
].irq
;
582 switch (info
->max14577
->dev_type
) {
583 case MAXIM_DEVICE_TYPE_MAX77836
:
584 irq_parsed
= max77836_parse_irq(info
, irq_type
);
586 case MAXIM_DEVICE_TYPE_MAX14577
:
588 irq_parsed
= max14577_parse_irq(info
, irq_type
);
593 dev_err(info
->dev
, "muic interrupt: irq %d occurred, skipped\n",
597 schedule_work(&info
->irq_work
);
602 static int max14577_muic_detect_accessory(struct max14577_muic_info
*info
)
609 mutex_lock(&info
->mutex
);
611 /* Read STATUSx register to detect accessory */
612 ret
= max14577_bulk_read(info
->max14577
->regmap
,
613 MAX14577_MUIC_REG_STATUS1
, info
->status
, 2);
615 dev_err(info
->dev
, "failed to read MUIC register\n");
616 mutex_unlock(&info
->mutex
);
620 adc
= max14577_muic_get_cable_type(info
, MAX14577_CABLE_GROUP_ADC
,
622 if (attached
&& adc
!= MAX14577_MUIC_ADC_OPEN
) {
623 ret
= max14577_muic_adc_handler(info
);
625 dev_err(info
->dev
, "Cannot detect accessory\n");
626 mutex_unlock(&info
->mutex
);
631 chg_type
= max14577_muic_get_cable_type(info
, MAX14577_CABLE_GROUP_CHG
,
633 if (attached
&& chg_type
!= MAX14577_CHARGER_TYPE_NONE
) {
634 ret
= max14577_muic_chg_handler(info
);
636 dev_err(info
->dev
, "Cannot detect charger accessory\n");
637 mutex_unlock(&info
->mutex
);
642 mutex_unlock(&info
->mutex
);
647 static void max14577_muic_detect_cable_wq(struct work_struct
*work
)
649 struct max14577_muic_info
*info
= container_of(to_delayed_work(work
),
650 struct max14577_muic_info
, wq_detcable
);
652 max14577_muic_detect_accessory(info
);
655 static int max14577_muic_probe(struct platform_device
*pdev
)
657 struct max14577
*max14577
= dev_get_drvdata(pdev
->dev
.parent
);
658 struct max14577_muic_info
*info
;
664 info
= devm_kzalloc(&pdev
->dev
, sizeof(*info
), GFP_KERNEL
);
668 info
->dev
= &pdev
->dev
;
669 info
->max14577
= max14577
;
671 platform_set_drvdata(pdev
, info
);
672 mutex_init(&info
->mutex
);
674 INIT_WORK(&info
->irq_work
, max14577_muic_irq_work
);
676 switch (max14577
->dev_type
) {
677 case MAXIM_DEVICE_TYPE_MAX77836
:
678 info
->muic_irqs
= max77836_muic_irqs
;
679 info
->muic_irqs_num
= ARRAY_SIZE(max77836_muic_irqs
);
681 case MAXIM_DEVICE_TYPE_MAX14577
:
683 info
->muic_irqs
= max14577_muic_irqs
;
684 info
->muic_irqs_num
= ARRAY_SIZE(max14577_muic_irqs
);
687 /* Support irq domain for max14577 MUIC device */
688 for (i
= 0; i
< info
->muic_irqs_num
; i
++) {
689 struct max14577_muic_irq
*muic_irq
= &info
->muic_irqs
[i
];
692 virq
= regmap_irq_get_virq(max14577
->irq_data
, muic_irq
->irq
);
695 muic_irq
->virq
= virq
;
697 ret
= devm_request_threaded_irq(&pdev
->dev
, virq
, NULL
,
698 max14577_muic_irq_handler
,
700 muic_irq
->name
, info
);
703 "failed: irq request (IRQ: %d, error :%d)\n",
709 /* Initialize extcon device */
710 info
->edev
= devm_extcon_dev_allocate(&pdev
->dev
,
711 max14577_extcon_cable
);
712 if (IS_ERR(info
->edev
)) {
713 dev_err(&pdev
->dev
, "failed to allocate memory for extcon\n");
717 ret
= devm_extcon_dev_register(&pdev
->dev
, info
->edev
);
719 dev_err(&pdev
->dev
, "failed to register extcon device\n");
723 /* Default h/w line path */
724 info
->path_usb
= CTRL1_SW_USB
;
725 info
->path_uart
= CTRL1_SW_UART
;
726 delay_jiffies
= msecs_to_jiffies(DELAY_MS_DEFAULT
);
728 /* Set initial path for UART */
729 max14577_muic_set_path(info
, info
->path_uart
, true);
731 /* Check revision number of MUIC device*/
732 ret
= max14577_read_reg(info
->max14577
->regmap
,
733 MAX14577_REG_DEVICEID
, &id
);
735 dev_err(&pdev
->dev
, "failed to read revision number\n");
738 dev_info(info
->dev
, "device ID : 0x%x\n", id
);
740 /* Set ADC debounce time */
741 max14577_muic_set_debounce_time(info
, ADC_DEBOUNCE_TIME_25MS
);
744 * Detect accessory after completing the initialization of platform
746 * - Use delayed workqueue to detect cable state and then
747 * notify cable state to notifiee/platform through uevent.
748 * After completing the booting of platform, the extcon provider
749 * driver should notify cable state to upper layer.
751 INIT_DELAYED_WORK(&info
->wq_detcable
, max14577_muic_detect_cable_wq
);
752 queue_delayed_work(system_power_efficient_wq
, &info
->wq_detcable
,
758 static int max14577_muic_remove(struct platform_device
*pdev
)
760 struct max14577_muic_info
*info
= platform_get_drvdata(pdev
);
762 cancel_work_sync(&info
->irq_work
);
767 static const struct platform_device_id max14577_muic_id
[] = {
768 { "max14577-muic", MAXIM_DEVICE_TYPE_MAX14577
, },
769 { "max77836-muic", MAXIM_DEVICE_TYPE_MAX77836
, },
772 MODULE_DEVICE_TABLE(platform
, max14577_muic_id
);
774 static struct platform_driver max14577_muic_driver
= {
776 .name
= "max14577-muic",
778 .probe
= max14577_muic_probe
,
779 .remove
= max14577_muic_remove
,
780 .id_table
= max14577_muic_id
,
783 module_platform_driver(max14577_muic_driver
);
785 MODULE_DESCRIPTION("Maxim 14577/77836 Extcon driver");
786 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>, Krzysztof Kozlowski <krzk@kernel.org>");
787 MODULE_LICENSE("GPL");
788 MODULE_ALIAS("platform:extcon-max14577");