2 * extcon-max14577.c - MAX14577 extcon driver to support MAX14577 MUIC
4 * Copyright (C) 2013 Samsung Electrnoics
5 * Chanwoo Choi <cw00.choi@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/i2c.h>
21 #include <linux/interrupt.h>
22 #include <linux/platform_device.h>
23 #include <linux/mfd/max14577.h>
24 #include <linux/mfd/max14577-private.h>
25 #include <linux/extcon.h>
27 #define DEV_NAME "max14577-muic"
28 #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
30 enum max14577_muic_adc_debounce_time
{
31 ADC_DEBOUNCE_TIME_5MS
= 0,
32 ADC_DEBOUNCE_TIME_10MS
,
33 ADC_DEBOUNCE_TIME_25MS
,
34 ADC_DEBOUNCE_TIME_38_62MS
,
37 enum max14577_muic_status
{
38 MAX14577_MUIC_STATUS1
= 0,
39 MAX14577_MUIC_STATUS2
= 1,
40 MAX14577_MUIC_STATUS_END
,
43 struct max14577_muic_info
{
45 struct max14577
*max14577
;
46 struct extcon_dev
*edev
;
49 u8 status
[MAX14577_MUIC_STATUS_END
];
53 struct work_struct irq_work
;
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.
62 struct delayed_work wq_detcable
;
65 * Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
66 * h/w path of COMP2/COMN1 on CONTROL1 register.
72 enum max14577_muic_cable_group
{
73 MAX14577_CABLE_GROUP_ADC
= 0,
74 MAX14577_CABLE_GROUP_CHG
,
78 * struct max14577_muic_irq
79 * @irq: the index of irq list of MUIC device.
80 * @name: the name of irq.
81 * @virq: the virtual irq to use irq domain
83 struct max14577_muic_irq
{
89 static struct max14577_muic_irq muic_irqs
[] = {
90 { MAX14577_IRQ_INT1_ADC
, "muic-ADC" },
91 { MAX14577_IRQ_INT1_ADCLOW
, "muic-ADCLOW" },
92 { MAX14577_IRQ_INT1_ADCERR
, "muic-ADCError" },
93 { MAX14577_IRQ_INT2_CHGTYP
, "muic-CHGTYP" },
94 { MAX14577_IRQ_INT2_CHGDETRUN
, "muic-CHGDETRUN" },
95 { MAX14577_IRQ_INT2_DCDTMR
, "muic-DCDTMR" },
96 { MAX14577_IRQ_INT2_DBCHG
, "muic-DBCHG" },
97 { MAX14577_IRQ_INT2_VBVOLT
, "muic-VBVOLT" },
100 /* Define supported accessory type */
101 enum max14577_muic_acc_type
{
102 MAX14577_MUIC_ADC_GROUND
= 0x0,
103 MAX14577_MUIC_ADC_SEND_END_BUTTON
,
104 MAX14577_MUIC_ADC_REMOTE_S1_BUTTON
,
105 MAX14577_MUIC_ADC_REMOTE_S2_BUTTON
,
106 MAX14577_MUIC_ADC_REMOTE_S3_BUTTON
,
107 MAX14577_MUIC_ADC_REMOTE_S4_BUTTON
,
108 MAX14577_MUIC_ADC_REMOTE_S5_BUTTON
,
109 MAX14577_MUIC_ADC_REMOTE_S6_BUTTON
,
110 MAX14577_MUIC_ADC_REMOTE_S7_BUTTON
,
111 MAX14577_MUIC_ADC_REMOTE_S8_BUTTON
,
112 MAX14577_MUIC_ADC_REMOTE_S9_BUTTON
,
113 MAX14577_MUIC_ADC_REMOTE_S10_BUTTON
,
114 MAX14577_MUIC_ADC_REMOTE_S11_BUTTON
,
115 MAX14577_MUIC_ADC_REMOTE_S12_BUTTON
,
116 MAX14577_MUIC_ADC_RESERVED_ACC_1
,
117 MAX14577_MUIC_ADC_RESERVED_ACC_2
,
118 MAX14577_MUIC_ADC_RESERVED_ACC_3
,
119 MAX14577_MUIC_ADC_RESERVED_ACC_4
,
120 MAX14577_MUIC_ADC_RESERVED_ACC_5
,
121 MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE2
,
122 MAX14577_MUIC_ADC_PHONE_POWERED_DEV
,
123 MAX14577_MUIC_ADC_TTY_CONVERTER
,
124 MAX14577_MUIC_ADC_UART_CABLE
,
125 MAX14577_MUIC_ADC_CEA936A_TYPE1_CHG
,
126 MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF
,
127 MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON
,
128 MAX14577_MUIC_ADC_AV_CABLE_NOLOAD
,
129 MAX14577_MUIC_ADC_CEA936A_TYPE2_CHG
,
130 MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF
,
131 MAX14577_MUIC_ADC_FACTORY_MODE_UART_ON
,
132 MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE1
, /* with Remote and Simple Ctrl */
133 MAX14577_MUIC_ADC_OPEN
,
136 /* max14577 MUIC device support below list of accessories(external connector) */
138 EXTCON_CABLE_USB
= 0,
140 EXTCON_CABLE_FAST_CHARGER
,
141 EXTCON_CABLE_SLOW_CHARGER
,
142 EXTCON_CABLE_CHARGE_DOWNSTREAM
,
143 EXTCON_CABLE_JIG_USB_ON
,
144 EXTCON_CABLE_JIG_USB_OFF
,
145 EXTCON_CABLE_JIG_UART_OFF
,
146 EXTCON_CABLE_JIG_UART_ON
,
151 static const char *max14577_extcon_cable
[] = {
152 [EXTCON_CABLE_USB
] = "USB",
153 [EXTCON_CABLE_TA
] = "TA",
154 [EXTCON_CABLE_FAST_CHARGER
] = "Fast-charger",
155 [EXTCON_CABLE_SLOW_CHARGER
] = "Slow-charger",
156 [EXTCON_CABLE_CHARGE_DOWNSTREAM
] = "Charge-downstream",
157 [EXTCON_CABLE_JIG_USB_ON
] = "JIG-USB-ON",
158 [EXTCON_CABLE_JIG_USB_OFF
] = "JIG-USB-OFF",
159 [EXTCON_CABLE_JIG_UART_OFF
] = "JIG-UART-OFF",
160 [EXTCON_CABLE_JIG_UART_ON
] = "JIG-UART-ON",
166 * max14577_muic_set_debounce_time - Set the debounce time of ADC
167 * @info: the instance including private data of max14577 MUIC
168 * @time: the debounce time of ADC
170 static int max14577_muic_set_debounce_time(struct max14577_muic_info
*info
,
171 enum max14577_muic_adc_debounce_time time
)
176 case ADC_DEBOUNCE_TIME_5MS
:
177 case ADC_DEBOUNCE_TIME_10MS
:
178 case ADC_DEBOUNCE_TIME_25MS
:
179 case ADC_DEBOUNCE_TIME_38_62MS
:
180 ret
= max14577_update_reg(info
->max14577
->regmap
,
181 MAX14577_MUIC_REG_CONTROL3
,
183 time
<< CTRL3_ADCDBSET_SHIFT
);
185 dev_err(info
->dev
, "failed to set ADC debounce time\n");
190 dev_err(info
->dev
, "invalid ADC debounce time\n");
198 * max14577_muic_set_path - Set hardware line according to attached cable
199 * @info: the instance including private data of max14577 MUIC
200 * @value: the path according to attached cable
201 * @attached: the state of cable (true:attached, false:detached)
203 * The max14577 MUIC device share outside H/W line among a varity of cables
204 * so, this function set internal path of H/W line according to the type of
207 static int max14577_muic_set_path(struct max14577_muic_info
*info
,
208 u8 val
, bool attached
)
213 /* Set open state to path before changing hw path */
214 ret
= max14577_update_reg(info
->max14577
->regmap
,
215 MAX14577_MUIC_REG_CONTROL1
,
216 CLEAR_IDBEN_MICEN_MASK
, CTRL1_SW_OPEN
);
218 dev_err(info
->dev
, "failed to update MUIC register\n");
225 ctrl1
= CTRL1_SW_OPEN
;
227 ret
= max14577_update_reg(info
->max14577
->regmap
,
228 MAX14577_MUIC_REG_CONTROL1
,
229 CLEAR_IDBEN_MICEN_MASK
, ctrl1
);
231 dev_err(info
->dev
, "failed to update MUIC register\n");
236 ctrl2
|= CTRL2_CPEN_MASK
; /* LowPwr=0, CPEn=1 */
238 ctrl2
|= CTRL2_LOWPWR_MASK
; /* LowPwr=1, CPEn=0 */
240 ret
= max14577_update_reg(info
->max14577
->regmap
,
241 MAX14577_REG_CONTROL2
,
242 CTRL2_LOWPWR_MASK
| CTRL2_CPEN_MASK
, ctrl2
);
244 dev_err(info
->dev
, "failed to update MUIC register\n");
249 "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n",
250 ctrl1
, ctrl2
, attached
? "attached" : "detached");
256 * max14577_muic_get_cable_type - Return cable type and check cable state
257 * @info: the instance including private data of max14577 MUIC
258 * @group: the path according to attached cable
259 * @attached: store cable state and return
261 * This function check the cable state either attached or detached,
262 * and then divide precise type of cable according to cable group.
263 * - max14577_CABLE_GROUP_ADC
264 * - max14577_CABLE_GROUP_CHG
266 static int max14577_muic_get_cable_type(struct max14577_muic_info
*info
,
267 enum max14577_muic_cable_group group
, bool *attached
)
274 case MAX14577_CABLE_GROUP_ADC
:
276 * Read ADC value to check cable type and decide cable state
277 * according to cable type
279 adc
= info
->status
[MAX14577_MUIC_STATUS1
] & STATUS1_ADC_MASK
;
280 adc
>>= STATUS1_ADC_SHIFT
;
283 * Check current cable state/cable type and store cable type
284 * (info->prev_cable_type) for handling cable when cable is
287 if (adc
== MAX14577_MUIC_ADC_OPEN
) {
290 cable_type
= info
->prev_cable_type
;
291 info
->prev_cable_type
= MAX14577_MUIC_ADC_OPEN
;
295 cable_type
= info
->prev_cable_type
= adc
;
298 case MAX14577_CABLE_GROUP_CHG
:
300 * Read charger type to check cable type and decide cable state
301 * according to type of charger cable.
303 chg_type
= info
->status
[MAX14577_MUIC_STATUS2
] &
305 chg_type
>>= STATUS2_CHGTYP_SHIFT
;
307 if (chg_type
== MAX14577_CHARGER_TYPE_NONE
) {
310 cable_type
= info
->prev_chg_type
;
311 info
->prev_chg_type
= MAX14577_CHARGER_TYPE_NONE
;
316 * Check current cable state/cable type and store cable
317 * type(info->prev_chg_type) for handling cable when
318 * charger cable is detached.
320 cable_type
= info
->prev_chg_type
= chg_type
;
325 dev_err(info
->dev
, "Unknown cable group (%d)\n", group
);
326 cable_type
= -EINVAL
;
333 static int max14577_muic_jig_handler(struct max14577_muic_info
*info
,
334 int cable_type
, bool attached
)
338 u8 path
= CTRL1_SW_OPEN
;
341 "external connector is %s (adc:0x%02x)\n",
342 attached
? "attached" : "detached", cable_type
);
344 switch (cable_type
) {
345 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF
: /* ADC_JIG_USB_OFF */
347 strcpy(cable_name
, "JIG-USB-OFF");
350 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON
: /* ADC_JIG_USB_ON */
352 strcpy(cable_name
, "JIG-USB-ON");
355 case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF
: /* ADC_JIG_UART_OFF */
357 strcpy(cable_name
, "JIG-UART-OFF");
358 path
= CTRL1_SW_UART
;
361 dev_err(info
->dev
, "failed to detect %s jig cable\n",
362 attached
? "attached" : "detached");
366 ret
= max14577_muic_set_path(info
, path
, attached
);
370 extcon_set_cable_state(info
->edev
, cable_name
, attached
);
375 static int max14577_muic_adc_handler(struct max14577_muic_info
*info
)
381 /* Check accessory state which is either detached or attached */
382 cable_type
= max14577_muic_get_cable_type(info
,
383 MAX14577_CABLE_GROUP_ADC
, &attached
);
386 "external connector is %s (adc:0x%02x, prev_adc:0x%x)\n",
387 attached
? "attached" : "detached", cable_type
,
388 info
->prev_cable_type
);
390 switch (cable_type
) {
391 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF
:
392 case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON
:
393 case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF
:
395 ret
= max14577_muic_jig_handler(info
, cable_type
, attached
);
399 case MAX14577_MUIC_ADC_GROUND
:
400 case MAX14577_MUIC_ADC_SEND_END_BUTTON
:
401 case MAX14577_MUIC_ADC_REMOTE_S1_BUTTON
:
402 case MAX14577_MUIC_ADC_REMOTE_S2_BUTTON
:
403 case MAX14577_MUIC_ADC_REMOTE_S3_BUTTON
:
404 case MAX14577_MUIC_ADC_REMOTE_S4_BUTTON
:
405 case MAX14577_MUIC_ADC_REMOTE_S5_BUTTON
:
406 case MAX14577_MUIC_ADC_REMOTE_S6_BUTTON
:
407 case MAX14577_MUIC_ADC_REMOTE_S7_BUTTON
:
408 case MAX14577_MUIC_ADC_REMOTE_S8_BUTTON
:
409 case MAX14577_MUIC_ADC_REMOTE_S9_BUTTON
:
410 case MAX14577_MUIC_ADC_REMOTE_S10_BUTTON
:
411 case MAX14577_MUIC_ADC_REMOTE_S11_BUTTON
:
412 case MAX14577_MUIC_ADC_REMOTE_S12_BUTTON
:
413 case MAX14577_MUIC_ADC_RESERVED_ACC_1
:
414 case MAX14577_MUIC_ADC_RESERVED_ACC_2
:
415 case MAX14577_MUIC_ADC_RESERVED_ACC_3
:
416 case MAX14577_MUIC_ADC_RESERVED_ACC_4
:
417 case MAX14577_MUIC_ADC_RESERVED_ACC_5
:
418 case MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE2
:
419 case MAX14577_MUIC_ADC_PHONE_POWERED_DEV
:
420 case MAX14577_MUIC_ADC_TTY_CONVERTER
:
421 case MAX14577_MUIC_ADC_UART_CABLE
:
422 case MAX14577_MUIC_ADC_CEA936A_TYPE1_CHG
:
423 case MAX14577_MUIC_ADC_AV_CABLE_NOLOAD
:
424 case MAX14577_MUIC_ADC_CEA936A_TYPE2_CHG
:
425 case MAX14577_MUIC_ADC_FACTORY_MODE_UART_ON
:
426 case MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE1
:
428 * This accessory isn't used in general case if it is specially
429 * needed to detect additional accessory, should implement
430 * proper operation when this accessory is attached/detached.
433 "accessory is %s but it isn't used (adc:0x%x)\n",
434 attached
? "attached" : "detached", cable_type
);
438 "failed to detect %s accessory (adc:0x%x)\n",
439 attached
? "attached" : "detached", cable_type
);
446 static int max14577_muic_chg_handler(struct max14577_muic_info
*info
)
452 chg_type
= max14577_muic_get_cable_type(info
,
453 MAX14577_CABLE_GROUP_CHG
, &attached
);
456 "external connector is %s(chg_type:0x%x, prev_chg_type:0x%x)\n",
457 attached
? "attached" : "detached",
458 chg_type
, info
->prev_chg_type
);
461 case MAX14577_CHARGER_TYPE_USB
:
463 ret
= max14577_muic_set_path(info
, info
->path_usb
, attached
);
467 extcon_set_cable_state(info
->edev
, "USB", attached
);
469 case MAX14577_CHARGER_TYPE_DEDICATED_CHG
:
470 extcon_set_cable_state(info
->edev
, "TA", attached
);
472 case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT
:
473 extcon_set_cable_state(info
->edev
,
474 "Charge-downstream", attached
);
476 case MAX14577_CHARGER_TYPE_SPECIAL_500MA
:
477 extcon_set_cable_state(info
->edev
, "Slow-charger", attached
);
479 case MAX14577_CHARGER_TYPE_SPECIAL_1A
:
480 extcon_set_cable_state(info
->edev
, "Fast-charger", attached
);
482 case MAX14577_CHARGER_TYPE_NONE
:
483 case MAX14577_CHARGER_TYPE_DEAD_BATTERY
:
487 "failed to detect %s accessory (chg_type:0x%x)\n",
488 attached
? "attached" : "detached", chg_type
);
495 static void max14577_muic_irq_work(struct work_struct
*work
)
497 struct max14577_muic_info
*info
= container_of(work
,
498 struct max14577_muic_info
, irq_work
);
504 mutex_lock(&info
->mutex
);
506 ret
= max14577_bulk_read(info
->max14577
->regmap
,
507 MAX14577_MUIC_REG_STATUS1
, info
->status
, 2);
509 dev_err(info
->dev
, "failed to read MUIC register\n");
510 mutex_unlock(&info
->mutex
);
515 ret
= max14577_muic_adc_handler(info
);
516 info
->irq_adc
= false;
519 ret
= max14577_muic_chg_handler(info
);
520 info
->irq_chg
= false;
524 dev_err(info
->dev
, "failed to handle MUIC interrupt\n");
526 mutex_unlock(&info
->mutex
);
531 static irqreturn_t
max14577_muic_irq_handler(int irq
, void *data
)
533 struct max14577_muic_info
*info
= data
;
534 int i
, irq_type
= -1;
537 * We may be called multiple times for different nested IRQ-s.
538 * Including changes in INT1_ADC and INT2_CGHTYP at once.
539 * However we only need to know whether it was ADC, charger
540 * or both interrupts so decode IRQ and turn on proper flags.
542 for (i
= 0; i
< ARRAY_SIZE(muic_irqs
); i
++)
543 if (irq
== muic_irqs
[i
].virq
)
544 irq_type
= muic_irqs
[i
].irq
;
547 case MAX14577_IRQ_INT1_ADC
:
548 case MAX14577_IRQ_INT1_ADCLOW
:
549 case MAX14577_IRQ_INT1_ADCERR
:
550 /* Handle all of accessory except for
551 type of charger accessory */
552 info
->irq_adc
= true;
554 case MAX14577_IRQ_INT2_CHGTYP
:
555 case MAX14577_IRQ_INT2_CHGDETRUN
:
556 case MAX14577_IRQ_INT2_DCDTMR
:
557 case MAX14577_IRQ_INT2_DBCHG
:
558 case MAX14577_IRQ_INT2_VBVOLT
:
559 /* Handle charger accessory */
560 info
->irq_chg
= true;
563 dev_err(info
->dev
, "muic interrupt: irq %d occurred, skipped\n",
567 schedule_work(&info
->irq_work
);
572 static int max14577_muic_detect_accessory(struct max14577_muic_info
*info
)
579 mutex_lock(&info
->mutex
);
581 /* Read STATUSx register to detect accessory */
582 ret
= max14577_bulk_read(info
->max14577
->regmap
,
583 MAX14577_MUIC_REG_STATUS1
, info
->status
, 2);
585 dev_err(info
->dev
, "failed to read MUIC register\n");
586 mutex_unlock(&info
->mutex
);
590 adc
= max14577_muic_get_cable_type(info
, MAX14577_CABLE_GROUP_ADC
,
592 if (attached
&& adc
!= MAX14577_MUIC_ADC_OPEN
) {
593 ret
= max14577_muic_adc_handler(info
);
595 dev_err(info
->dev
, "Cannot detect accessory\n");
596 mutex_unlock(&info
->mutex
);
601 chg_type
= max14577_muic_get_cable_type(info
, MAX14577_CABLE_GROUP_CHG
,
603 if (attached
&& chg_type
!= MAX14577_CHARGER_TYPE_NONE
) {
604 ret
= max14577_muic_chg_handler(info
);
606 dev_err(info
->dev
, "Cannot detect charger accessory\n");
607 mutex_unlock(&info
->mutex
);
612 mutex_unlock(&info
->mutex
);
617 static void max14577_muic_detect_cable_wq(struct work_struct
*work
)
619 struct max14577_muic_info
*info
= container_of(to_delayed_work(work
),
620 struct max14577_muic_info
, wq_detcable
);
622 max14577_muic_detect_accessory(info
);
625 static int max14577_muic_probe(struct platform_device
*pdev
)
627 struct max14577
*max14577
= dev_get_drvdata(pdev
->dev
.parent
);
628 struct max14577_muic_info
*info
;
634 info
= devm_kzalloc(&pdev
->dev
, sizeof(*info
), GFP_KERNEL
);
636 dev_err(&pdev
->dev
, "failed to allocate memory\n");
639 info
->dev
= &pdev
->dev
;
640 info
->max14577
= max14577
;
642 platform_set_drvdata(pdev
, info
);
643 mutex_init(&info
->mutex
);
645 INIT_WORK(&info
->irq_work
, max14577_muic_irq_work
);
647 /* Support irq domain for max14577 MUIC device */
648 for (i
= 0; i
< ARRAY_SIZE(muic_irqs
); i
++) {
649 struct max14577_muic_irq
*muic_irq
= &muic_irqs
[i
];
650 unsigned int virq
= 0;
652 virq
= regmap_irq_get_virq(max14577
->irq_data
, muic_irq
->irq
);
655 muic_irq
->virq
= virq
;
657 ret
= devm_request_threaded_irq(&pdev
->dev
, virq
, NULL
,
658 max14577_muic_irq_handler
,
660 muic_irq
->name
, info
);
663 "failed: irq request (IRQ: %d,"
670 /* Initialize extcon device */
671 info
->edev
= devm_kzalloc(&pdev
->dev
, sizeof(*info
->edev
), GFP_KERNEL
);
673 dev_err(&pdev
->dev
, "failed to allocate memory for extcon\n");
676 info
->edev
->name
= DEV_NAME
;
677 info
->edev
->supported_cable
= max14577_extcon_cable
;
678 ret
= extcon_dev_register(info
->edev
);
680 dev_err(&pdev
->dev
, "failed to register extcon device\n");
684 /* Default h/w line path */
685 info
->path_usb
= CTRL1_SW_USB
;
686 info
->path_uart
= CTRL1_SW_UART
;
687 delay_jiffies
= msecs_to_jiffies(DELAY_MS_DEFAULT
);
689 /* Set initial path for UART */
690 max14577_muic_set_path(info
, info
->path_uart
, true);
692 /* Check revision number of MUIC device*/
693 ret
= max14577_read_reg(info
->max14577
->regmap
,
694 MAX14577_REG_DEVICEID
, &id
);
696 dev_err(&pdev
->dev
, "failed to read revision number\n");
699 dev_info(info
->dev
, "device ID : 0x%x\n", id
);
701 /* Set ADC debounce time */
702 max14577_muic_set_debounce_time(info
, ADC_DEBOUNCE_TIME_25MS
);
705 * Detect accessory after completing the initialization of platform
707 * - Use delayed workqueue to detect cable state and then
708 * notify cable state to notifiee/platform through uevent.
709 * After completing the booting of platform, the extcon provider
710 * driver should notify cable state to upper layer.
712 INIT_DELAYED_WORK(&info
->wq_detcable
, max14577_muic_detect_cable_wq
);
713 ret
= queue_delayed_work(system_power_efficient_wq
, &info
->wq_detcable
,
717 "failed to schedule delayed work for cable detect\n");
724 extcon_dev_unregister(info
->edev
);
728 static int max14577_muic_remove(struct platform_device
*pdev
)
730 struct max14577_muic_info
*info
= platform_get_drvdata(pdev
);
732 cancel_work_sync(&info
->irq_work
);
733 extcon_dev_unregister(info
->edev
);
738 static struct platform_driver max14577_muic_driver
= {
741 .owner
= THIS_MODULE
,
743 .probe
= max14577_muic_probe
,
744 .remove
= max14577_muic_remove
,
747 module_platform_driver(max14577_muic_driver
);
749 MODULE_DESCRIPTION("MAXIM 14577 Extcon driver");
750 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
751 MODULE_LICENSE("GPL");
752 MODULE_ALIAS("platform:extcon-max14577");