1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * extcon-sm5502.c - Silicon Mitus SM5502 extcon drvier to support USB switches
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd
6 * Author: Chanwoo Choi <cw00.choi@samsung.com>
10 #include <linux/i2c.h>
11 #include <linux/interrupt.h>
12 #include <linux/irqdomain.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/platform_device.h>
16 #include <linux/regmap.h>
17 #include <linux/slab.h>
18 #include <linux/extcon-provider.h>
20 #include "extcon-sm5502.h"
22 #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
36 struct sm5502_muic_info
{
38 struct extcon_dev
*edev
;
40 struct i2c_client
*i2c
;
41 struct regmap
*regmap
;
43 struct regmap_irq_chip_data
*irq_data
;
44 struct muic_irq
*muic_irqs
;
45 unsigned int num_muic_irqs
;
49 struct work_struct irq_work
;
51 struct reg_data
*reg_data
;
52 unsigned int num_reg_data
;
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 value of SM5502 register to bring up MUIC device. */
66 static struct reg_data sm5502_reg_data
[] = {
68 .reg
= SM5502_REG_CONTROL
,
69 .val
= SM5502_REG_CONTROL_MASK_INT_MASK
,
72 .reg
= SM5502_REG_INTMASK1
,
73 .val
= SM5502_REG_INTM1_KP_MASK
74 | SM5502_REG_INTM1_LKP_MASK
75 | SM5502_REG_INTM1_LKR_MASK
,
78 .reg
= SM5502_REG_INTMASK2
,
79 .val
= SM5502_REG_INTM2_VBUS_DET_MASK
80 | SM5502_REG_INTM2_REV_ACCE_MASK
81 | SM5502_REG_INTM2_ADC_CHG_MASK
82 | SM5502_REG_INTM2_STUCK_KEY_MASK
83 | SM5502_REG_INTM2_STUCK_KEY_RCV_MASK
84 | SM5502_REG_INTM2_MHL_MASK
,
90 /* List of detectable cables */
91 static const unsigned int sm5502_extcon_cable
[] = {
99 /* Define supported accessory type */
100 enum sm5502_muic_acc_type
{
101 SM5502_MUIC_ADC_GROUND
= 0x0,
102 SM5502_MUIC_ADC_SEND_END_BUTTON
,
103 SM5502_MUIC_ADC_REMOTE_S1_BUTTON
,
104 SM5502_MUIC_ADC_REMOTE_S2_BUTTON
,
105 SM5502_MUIC_ADC_REMOTE_S3_BUTTON
,
106 SM5502_MUIC_ADC_REMOTE_S4_BUTTON
,
107 SM5502_MUIC_ADC_REMOTE_S5_BUTTON
,
108 SM5502_MUIC_ADC_REMOTE_S6_BUTTON
,
109 SM5502_MUIC_ADC_REMOTE_S7_BUTTON
,
110 SM5502_MUIC_ADC_REMOTE_S8_BUTTON
,
111 SM5502_MUIC_ADC_REMOTE_S9_BUTTON
,
112 SM5502_MUIC_ADC_REMOTE_S10_BUTTON
,
113 SM5502_MUIC_ADC_REMOTE_S11_BUTTON
,
114 SM5502_MUIC_ADC_REMOTE_S12_BUTTON
,
115 SM5502_MUIC_ADC_RESERVED_ACC_1
,
116 SM5502_MUIC_ADC_RESERVED_ACC_2
,
117 SM5502_MUIC_ADC_RESERVED_ACC_3
,
118 SM5502_MUIC_ADC_RESERVED_ACC_4
,
119 SM5502_MUIC_ADC_RESERVED_ACC_5
,
120 SM5502_MUIC_ADC_AUDIO_TYPE2
,
121 SM5502_MUIC_ADC_PHONE_POWERED_DEV
,
122 SM5502_MUIC_ADC_TTY_CONVERTER
,
123 SM5502_MUIC_ADC_UART_CABLE
,
124 SM5502_MUIC_ADC_TYPE1_CHARGER
,
125 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_USB
,
126 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_USB
,
127 SM5502_MUIC_ADC_AUDIO_VIDEO_CABLE
,
128 SM5502_MUIC_ADC_TYPE2_CHARGER
,
129 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_UART
,
130 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_UART
,
131 SM5502_MUIC_ADC_AUDIO_TYPE1
,
132 SM5502_MUIC_ADC_OPEN
= 0x1f,
135 * The below accessories have same ADC value (0x1f or 0x1e).
136 * So, Device type1 is used to separate specific accessory.
138 /* |---------|--ADC| */
140 SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE
= 0x3e, /* | 001|11110| */
141 SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END
= 0x5e, /* | 010|11110| */
142 /* |Dev Type1|--ADC| */
143 SM5502_MUIC_ADC_OPEN_USB
= 0x5f, /* | 010|11111| */
144 SM5502_MUIC_ADC_OPEN_TA
= 0xdf, /* | 110|11111| */
145 SM5502_MUIC_ADC_OPEN_USB_OTG
= 0xff, /* | 111|11111| */
148 /* List of supported interrupt for SM5502 */
149 static struct muic_irq sm5502_muic_irqs
[] = {
150 { SM5502_IRQ_INT1_ATTACH
, "muic-attach" },
151 { SM5502_IRQ_INT1_DETACH
, "muic-detach" },
152 { SM5502_IRQ_INT1_KP
, "muic-kp" },
153 { SM5502_IRQ_INT1_LKP
, "muic-lkp" },
154 { SM5502_IRQ_INT1_LKR
, "muic-lkr" },
155 { SM5502_IRQ_INT1_OVP_EVENT
, "muic-ovp-event" },
156 { SM5502_IRQ_INT1_OCP_EVENT
, "muic-ocp-event" },
157 { SM5502_IRQ_INT1_OVP_OCP_DIS
, "muic-ovp-ocp-dis" },
158 { SM5502_IRQ_INT2_VBUS_DET
, "muic-vbus-det" },
159 { SM5502_IRQ_INT2_REV_ACCE
, "muic-rev-acce" },
160 { SM5502_IRQ_INT2_ADC_CHG
, "muic-adc-chg" },
161 { SM5502_IRQ_INT2_STUCK_KEY
, "muic-stuck-key" },
162 { SM5502_IRQ_INT2_STUCK_KEY_RCV
, "muic-stuck-key-rcv" },
163 { SM5502_IRQ_INT2_MHL
, "muic-mhl" },
166 /* Define interrupt list of SM5502 to register regmap_irq */
167 static const struct regmap_irq sm5502_irqs
[] = {
168 /* INT1 interrupts */
169 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_ATTACH_MASK
, },
170 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_DETACH_MASK
, },
171 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_KP_MASK
, },
172 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_LKP_MASK
, },
173 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_LKR_MASK
, },
174 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_OVP_EVENT_MASK
, },
175 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_OCP_EVENT_MASK
, },
176 { .reg_offset
= 0, .mask
= SM5502_IRQ_INT1_OVP_OCP_DIS_MASK
, },
178 /* INT2 interrupts */
179 { .reg_offset
= 1, .mask
= SM5502_IRQ_INT2_VBUS_DET_MASK
,},
180 { .reg_offset
= 1, .mask
= SM5502_IRQ_INT2_REV_ACCE_MASK
, },
181 { .reg_offset
= 1, .mask
= SM5502_IRQ_INT2_ADC_CHG_MASK
, },
182 { .reg_offset
= 1, .mask
= SM5502_IRQ_INT2_STUCK_KEY_MASK
, },
183 { .reg_offset
= 1, .mask
= SM5502_IRQ_INT2_STUCK_KEY_RCV_MASK
, },
184 { .reg_offset
= 1, .mask
= SM5502_IRQ_INT2_MHL_MASK
, },
187 static const struct regmap_irq_chip sm5502_muic_irq_chip
= {
189 .status_base
= SM5502_REG_INT1
,
190 .mask_base
= SM5502_REG_INTMASK1
,
191 .mask_invert
= false,
194 .num_irqs
= ARRAY_SIZE(sm5502_irqs
),
197 /* Define regmap configuration of SM5502 for I2C communication */
198 static bool sm5502_muic_volatile_reg(struct device
*dev
, unsigned int reg
)
201 case SM5502_REG_INTMASK1
:
202 case SM5502_REG_INTMASK2
:
210 static const struct regmap_config sm5502_muic_regmap_config
= {
213 .volatile_reg
= sm5502_muic_volatile_reg
,
214 .max_register
= SM5502_REG_END
,
217 /* Change DM_CON/DP_CON/VBUSIN switch according to cable type */
218 static int sm5502_muic_set_path(struct sm5502_muic_info
*info
,
219 unsigned int con_sw
, unsigned int vbus_sw
,
225 con_sw
= DM_DP_SWITCH_OPEN
;
226 vbus_sw
= VBUSIN_SWITCH_OPEN
;
230 case DM_DP_SWITCH_OPEN
:
231 case DM_DP_SWITCH_USB
:
232 case DM_DP_SWITCH_AUDIO
:
233 case DM_DP_SWITCH_UART
:
234 ret
= regmap_update_bits(info
->regmap
, SM5502_REG_MANUAL_SW1
,
235 SM5502_REG_MANUAL_SW1_DP_MASK
|
236 SM5502_REG_MANUAL_SW1_DM_MASK
,
240 "cannot update DM_CON/DP_CON switch\n");
245 dev_err(info
->dev
, "Unknown DM_CON/DP_CON switch type (%d)\n",
251 case VBUSIN_SWITCH_OPEN
:
252 case VBUSIN_SWITCH_VBUSOUT
:
253 case VBUSIN_SWITCH_MIC
:
254 case VBUSIN_SWITCH_VBUSOUT_WITH_USB
:
255 ret
= regmap_update_bits(info
->regmap
, SM5502_REG_MANUAL_SW1
,
256 SM5502_REG_MANUAL_SW1_VBUSIN_MASK
,
260 "cannot update VBUSIN switch\n");
265 dev_err(info
->dev
, "Unknown VBUS switch type (%d)\n", vbus_sw
);
272 /* Return cable type of attached or detached accessories */
273 static unsigned int sm5502_muic_get_cable_type(struct sm5502_muic_info
*info
)
275 unsigned int cable_type
= -1, adc
, dev_type1
;
278 /* Read ADC value according to external cable or button */
279 ret
= regmap_read(info
->regmap
, SM5502_REG_ADC
, &adc
);
281 dev_err(info
->dev
, "failed to read ADC register\n");
286 * If ADC is SM5502_MUIC_ADC_GROUND(0x0), external cable hasn't
287 * connected with to MUIC device.
289 cable_type
= adc
& SM5502_REG_ADC_MASK
;
290 if (cable_type
== SM5502_MUIC_ADC_GROUND
)
291 return SM5502_MUIC_ADC_GROUND
;
293 switch (cable_type
) {
294 case SM5502_MUIC_ADC_GROUND
:
295 case SM5502_MUIC_ADC_SEND_END_BUTTON
:
296 case SM5502_MUIC_ADC_REMOTE_S1_BUTTON
:
297 case SM5502_MUIC_ADC_REMOTE_S2_BUTTON
:
298 case SM5502_MUIC_ADC_REMOTE_S3_BUTTON
:
299 case SM5502_MUIC_ADC_REMOTE_S4_BUTTON
:
300 case SM5502_MUIC_ADC_REMOTE_S5_BUTTON
:
301 case SM5502_MUIC_ADC_REMOTE_S6_BUTTON
:
302 case SM5502_MUIC_ADC_REMOTE_S7_BUTTON
:
303 case SM5502_MUIC_ADC_REMOTE_S8_BUTTON
:
304 case SM5502_MUIC_ADC_REMOTE_S9_BUTTON
:
305 case SM5502_MUIC_ADC_REMOTE_S10_BUTTON
:
306 case SM5502_MUIC_ADC_REMOTE_S11_BUTTON
:
307 case SM5502_MUIC_ADC_REMOTE_S12_BUTTON
:
308 case SM5502_MUIC_ADC_RESERVED_ACC_1
:
309 case SM5502_MUIC_ADC_RESERVED_ACC_2
:
310 case SM5502_MUIC_ADC_RESERVED_ACC_3
:
311 case SM5502_MUIC_ADC_RESERVED_ACC_4
:
312 case SM5502_MUIC_ADC_RESERVED_ACC_5
:
313 case SM5502_MUIC_ADC_AUDIO_TYPE2
:
314 case SM5502_MUIC_ADC_PHONE_POWERED_DEV
:
315 case SM5502_MUIC_ADC_TTY_CONVERTER
:
316 case SM5502_MUIC_ADC_UART_CABLE
:
317 case SM5502_MUIC_ADC_TYPE1_CHARGER
:
318 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_USB
:
319 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_USB
:
320 case SM5502_MUIC_ADC_AUDIO_VIDEO_CABLE
:
321 case SM5502_MUIC_ADC_TYPE2_CHARGER
:
322 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_UART
:
323 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_UART
:
325 case SM5502_MUIC_ADC_AUDIO_TYPE1
:
327 * Check whether cable type is
328 * SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE
329 * or SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END
330 * by using Button event.
333 case SM5502_MUIC_ADC_OPEN
:
334 ret
= regmap_read(info
->regmap
, SM5502_REG_DEV_TYPE1
,
337 dev_err(info
->dev
, "failed to read DEV_TYPE1 reg\n");
342 case SM5502_REG_DEV_TYPE1_USB_SDP_MASK
:
343 cable_type
= SM5502_MUIC_ADC_OPEN_USB
;
345 case SM5502_REG_DEV_TYPE1_DEDICATED_CHG_MASK
:
346 cable_type
= SM5502_MUIC_ADC_OPEN_TA
;
348 case SM5502_REG_DEV_TYPE1_USB_OTG_MASK
:
349 cable_type
= SM5502_MUIC_ADC_OPEN_USB_OTG
;
353 "cannot identify the cable type: adc(0x%x)\n",
360 "failed to identify the cable type: adc(0x%x)\n", adc
);
367 static int sm5502_muic_cable_handler(struct sm5502_muic_info
*info
,
370 static unsigned int prev_cable_type
= SM5502_MUIC_ADC_GROUND
;
371 unsigned int cable_type
= SM5502_MUIC_ADC_GROUND
;
372 unsigned int con_sw
= DM_DP_SWITCH_OPEN
;
373 unsigned int vbus_sw
= VBUSIN_SWITCH_OPEN
;
377 /* Get the type of attached or detached cable */
379 cable_type
= sm5502_muic_get_cable_type(info
);
381 cable_type
= prev_cable_type
;
382 prev_cable_type
= cable_type
;
384 switch (cable_type
) {
385 case SM5502_MUIC_ADC_OPEN_USB
:
387 con_sw
= DM_DP_SWITCH_USB
;
388 vbus_sw
= VBUSIN_SWITCH_VBUSOUT_WITH_USB
;
390 case SM5502_MUIC_ADC_OPEN_TA
:
391 id
= EXTCON_CHG_USB_DCP
;
392 con_sw
= DM_DP_SWITCH_OPEN
;
393 vbus_sw
= VBUSIN_SWITCH_VBUSOUT
;
395 case SM5502_MUIC_ADC_OPEN_USB_OTG
:
396 id
= EXTCON_USB_HOST
;
397 con_sw
= DM_DP_SWITCH_USB
;
398 vbus_sw
= VBUSIN_SWITCH_OPEN
;
402 "cannot handle this cable_type (0x%x)\n", cable_type
);
406 /* Change internal hardware path(DM_CON/DP_CON, VBUSIN) */
407 ret
= sm5502_muic_set_path(info
, con_sw
, vbus_sw
, attached
);
411 /* Change the state of external accessory */
412 extcon_set_state_sync(info
->edev
, id
, attached
);
413 if (id
== EXTCON_USB
)
414 extcon_set_state_sync(info
->edev
, EXTCON_CHG_USB_SDP
,
420 static void sm5502_muic_irq_work(struct work_struct
*work
)
422 struct sm5502_muic_info
*info
= container_of(work
,
423 struct sm5502_muic_info
, irq_work
);
429 mutex_lock(&info
->mutex
);
431 /* Detect attached or detached cables */
432 if (info
->irq_attach
) {
433 ret
= sm5502_muic_cable_handler(info
, true);
434 info
->irq_attach
= false;
436 if (info
->irq_detach
) {
437 ret
= sm5502_muic_cable_handler(info
, false);
438 info
->irq_detach
= false;
442 dev_err(info
->dev
, "failed to handle MUIC interrupt\n");
444 mutex_unlock(&info
->mutex
);
448 * Sets irq_attach or irq_detach in sm5502_muic_info and returns 0.
449 * Returns -ESRCH if irq_type does not match registered IRQ for this dev type.
451 static int sm5502_parse_irq(struct sm5502_muic_info
*info
, int irq_type
)
454 case SM5502_IRQ_INT1_ATTACH
:
455 info
->irq_attach
= true;
457 case SM5502_IRQ_INT1_DETACH
:
458 info
->irq_detach
= true;
460 case SM5502_IRQ_INT1_KP
:
461 case SM5502_IRQ_INT1_LKP
:
462 case SM5502_IRQ_INT1_LKR
:
463 case SM5502_IRQ_INT1_OVP_EVENT
:
464 case SM5502_IRQ_INT1_OCP_EVENT
:
465 case SM5502_IRQ_INT1_OVP_OCP_DIS
:
466 case SM5502_IRQ_INT2_VBUS_DET
:
467 case SM5502_IRQ_INT2_REV_ACCE
:
468 case SM5502_IRQ_INT2_ADC_CHG
:
469 case SM5502_IRQ_INT2_STUCK_KEY
:
470 case SM5502_IRQ_INT2_STUCK_KEY_RCV
:
471 case SM5502_IRQ_INT2_MHL
:
479 static irqreturn_t
sm5502_muic_irq_handler(int irq
, void *data
)
481 struct sm5502_muic_info
*info
= data
;
482 int i
, irq_type
= -1, ret
;
484 for (i
= 0; i
< info
->num_muic_irqs
; i
++)
485 if (irq
== info
->muic_irqs
[i
].virq
)
486 irq_type
= info
->muic_irqs
[i
].irq
;
488 ret
= sm5502_parse_irq(info
, irq_type
);
490 dev_warn(info
->dev
, "cannot handle is interrupt:%d\n",
494 schedule_work(&info
->irq_work
);
499 static void sm5502_muic_detect_cable_wq(struct work_struct
*work
)
501 struct sm5502_muic_info
*info
= container_of(to_delayed_work(work
),
502 struct sm5502_muic_info
, wq_detcable
);
505 /* Notify the state of connector cable or not */
506 ret
= sm5502_muic_cable_handler(info
, true);
508 dev_warn(info
->dev
, "failed to detect cable state\n");
511 static void sm5502_init_dev_type(struct sm5502_muic_info
*info
)
513 unsigned int reg_data
, vendor_id
, version_id
;
516 /* To test I2C, Print version_id and vendor_id of SM5502 */
517 ret
= regmap_read(info
->regmap
, SM5502_REG_DEVICE_ID
, ®_data
);
520 "failed to read DEVICE_ID register: %d\n", ret
);
524 vendor_id
= ((reg_data
& SM5502_REG_DEVICE_ID_VENDOR_MASK
) >>
525 SM5502_REG_DEVICE_ID_VENDOR_SHIFT
);
526 version_id
= ((reg_data
& SM5502_REG_DEVICE_ID_VERSION_MASK
) >>
527 SM5502_REG_DEVICE_ID_VERSION_SHIFT
);
529 dev_info(info
->dev
, "Device type: version: 0x%x, vendor: 0x%x\n",
530 version_id
, vendor_id
);
532 /* Initiazle the register of SM5502 device to bring-up */
533 for (i
= 0; i
< info
->num_reg_data
; i
++) {
534 unsigned int val
= 0;
536 if (!info
->reg_data
[i
].invert
)
537 val
|= ~info
->reg_data
[i
].val
;
539 val
= info
->reg_data
[i
].val
;
540 regmap_write(info
->regmap
, info
->reg_data
[i
].reg
, val
);
544 static int sm5022_muic_i2c_probe(struct i2c_client
*i2c
,
545 const struct i2c_device_id
*id
)
547 struct device_node
*np
= i2c
->dev
.of_node
;
548 struct sm5502_muic_info
*info
;
549 int i
, ret
, irq_flags
;
554 info
= devm_kzalloc(&i2c
->dev
, sizeof(*info
), GFP_KERNEL
);
557 i2c_set_clientdata(i2c
, info
);
559 info
->dev
= &i2c
->dev
;
561 info
->irq
= i2c
->irq
;
562 info
->muic_irqs
= sm5502_muic_irqs
;
563 info
->num_muic_irqs
= ARRAY_SIZE(sm5502_muic_irqs
);
564 info
->reg_data
= sm5502_reg_data
;
565 info
->num_reg_data
= ARRAY_SIZE(sm5502_reg_data
);
567 mutex_init(&info
->mutex
);
569 INIT_WORK(&info
->irq_work
, sm5502_muic_irq_work
);
571 info
->regmap
= devm_regmap_init_i2c(i2c
, &sm5502_muic_regmap_config
);
572 if (IS_ERR(info
->regmap
)) {
573 ret
= PTR_ERR(info
->regmap
);
574 dev_err(info
->dev
, "failed to allocate register map: %d\n",
579 /* Support irq domain for SM5502 MUIC device */
580 irq_flags
= IRQF_TRIGGER_FALLING
| IRQF_ONESHOT
| IRQF_SHARED
;
581 ret
= regmap_add_irq_chip(info
->regmap
, info
->irq
, irq_flags
, 0,
582 &sm5502_muic_irq_chip
, &info
->irq_data
);
584 dev_err(info
->dev
, "failed to request IRQ %d: %d\n",
589 for (i
= 0; i
< info
->num_muic_irqs
; i
++) {
590 struct muic_irq
*muic_irq
= &info
->muic_irqs
[i
];
593 virq
= regmap_irq_get_virq(info
->irq_data
, muic_irq
->irq
);
596 muic_irq
->virq
= virq
;
598 ret
= devm_request_threaded_irq(info
->dev
, virq
, NULL
,
599 sm5502_muic_irq_handler
,
601 muic_irq
->name
, info
);
604 "failed: irq request (IRQ: %d, error :%d)\n",
610 /* Allocate extcon device */
611 info
->edev
= devm_extcon_dev_allocate(info
->dev
, sm5502_extcon_cable
);
612 if (IS_ERR(info
->edev
)) {
613 dev_err(info
->dev
, "failed to allocate memory for extcon\n");
617 /* Register extcon device */
618 ret
= devm_extcon_dev_register(info
->dev
, info
->edev
);
620 dev_err(info
->dev
, "failed to register extcon device\n");
625 * Detect accessory after completing the initialization of platform
627 * - Use delayed workqueue to detect cable state and then
628 * notify cable state to notifiee/platform through uevent.
629 * After completing the booting of platform, the extcon provider
630 * driver should notify cable state to upper layer.
632 INIT_DELAYED_WORK(&info
->wq_detcable
, sm5502_muic_detect_cable_wq
);
633 queue_delayed_work(system_power_efficient_wq
, &info
->wq_detcable
,
634 msecs_to_jiffies(DELAY_MS_DEFAULT
));
636 /* Initialize SM5502 device and print vendor id and version id */
637 sm5502_init_dev_type(info
);
642 static int sm5502_muic_i2c_remove(struct i2c_client
*i2c
)
644 struct sm5502_muic_info
*info
= i2c_get_clientdata(i2c
);
646 regmap_del_irq_chip(info
->irq
, info
->irq_data
);
651 static const struct of_device_id sm5502_dt_match
[] = {
652 { .compatible
= "siliconmitus,sm5502-muic" },
655 MODULE_DEVICE_TABLE(of
, sm5502_dt_match
);
657 #ifdef CONFIG_PM_SLEEP
658 static int sm5502_muic_suspend(struct device
*dev
)
660 struct i2c_client
*i2c
= to_i2c_client(dev
);
661 struct sm5502_muic_info
*info
= i2c_get_clientdata(i2c
);
663 enable_irq_wake(info
->irq
);
668 static int sm5502_muic_resume(struct device
*dev
)
670 struct i2c_client
*i2c
= to_i2c_client(dev
);
671 struct sm5502_muic_info
*info
= i2c_get_clientdata(i2c
);
673 disable_irq_wake(info
->irq
);
679 static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops
,
680 sm5502_muic_suspend
, sm5502_muic_resume
);
682 static const struct i2c_device_id sm5502_i2c_id
[] = {
683 { "sm5502", TYPE_SM5502
},
686 MODULE_DEVICE_TABLE(i2c
, sm5502_i2c_id
);
688 static struct i2c_driver sm5502_muic_i2c_driver
= {
691 .pm
= &sm5502_muic_pm_ops
,
692 .of_match_table
= sm5502_dt_match
,
694 .probe
= sm5022_muic_i2c_probe
,
695 .remove
= sm5502_muic_i2c_remove
,
696 .id_table
= sm5502_i2c_id
,
699 static int __init
sm5502_muic_i2c_init(void)
701 return i2c_add_driver(&sm5502_muic_i2c_driver
);
703 subsys_initcall(sm5502_muic_i2c_init
);
705 MODULE_DESCRIPTION("Silicon Mitus SM5502 Extcon driver");
706 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
707 MODULE_LICENSE("GPL");