2 * extcon-sm5502.c - Silicon Mitus SM5502 extcon drvier to support USB switches
4 * Copyright (c) 2014 Samsung Electronics Co., Ltd
5 * Author: Chanwoo Choi <cw00.choi@samsung.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 #include <linux/err.h>
14 #include <linux/i2c.h>
15 #include <linux/input.h>
16 #include <linux/interrupt.h>
17 #include <linux/irqdomain.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/regmap.h>
22 #include <linux/slab.h>
23 #include <linux/extcon.h>
25 #include "extcon-sm5502.h"
27 #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */
41 struct sm5502_muic_info {
43 struct extcon_dev *edev;
45 struct i2c_client *i2c;
46 struct regmap *regmap;
48 struct regmap_irq_chip_data *irq_data;
49 struct muic_irq *muic_irqs;
50 unsigned int num_muic_irqs;
54 struct work_struct irq_work;
56 struct reg_data *reg_data;
57 unsigned int num_reg_data;
62 * Use delayed workqueue to detect cable state and then
63 * notify cable state to notifiee/platform through uevent.
64 * After completing the booting of platform, the extcon provider
65 * driver should notify cable state to upper layer.
67 struct delayed_work wq_detcable;
70 /* Default value of SM5502 register to bring up MUIC device. */
71 static struct reg_data sm5502_reg_data[] = {
73 .reg = SM5502_REG_CONTROL,
74 .val = SM5502_REG_CONTROL_MASK_INT_MASK,
77 .reg = SM5502_REG_INTMASK1,
78 .val = SM5502_REG_INTM1_KP_MASK
79 | SM5502_REG_INTM1_LKP_MASK
80 | SM5502_REG_INTM1_LKR_MASK,
83 .reg = SM5502_REG_INTMASK2,
84 .val = SM5502_REG_INTM2_VBUS_DET_MASK
85 | SM5502_REG_INTM2_REV_ACCE_MASK
86 | SM5502_REG_INTM2_ADC_CHG_MASK
87 | SM5502_REG_INTM2_STUCK_KEY_MASK
88 | SM5502_REG_INTM2_STUCK_KEY_RCV_MASK
89 | SM5502_REG_INTM2_MHL_MASK,
95 /* List of detectable cables */
98 EXTCON_CABLE_USB_HOST,
104 static const char *sm5502_extcon_cable[] = {
105 [EXTCON_CABLE_USB] = "USB",
106 [EXTCON_CABLE_USB_HOST] = "USB-Host",
107 [EXTCON_CABLE_TA] = "TA",
111 /* Define supported accessory type */
112 enum sm5502_muic_acc_type {
113 SM5502_MUIC_ADC_GROUND = 0x0,
114 SM5502_MUIC_ADC_SEND_END_BUTTON,
115 SM5502_MUIC_ADC_REMOTE_S1_BUTTON,
116 SM5502_MUIC_ADC_REMOTE_S2_BUTTON,
117 SM5502_MUIC_ADC_REMOTE_S3_BUTTON,
118 SM5502_MUIC_ADC_REMOTE_S4_BUTTON,
119 SM5502_MUIC_ADC_REMOTE_S5_BUTTON,
120 SM5502_MUIC_ADC_REMOTE_S6_BUTTON,
121 SM5502_MUIC_ADC_REMOTE_S7_BUTTON,
122 SM5502_MUIC_ADC_REMOTE_S8_BUTTON,
123 SM5502_MUIC_ADC_REMOTE_S9_BUTTON,
124 SM5502_MUIC_ADC_REMOTE_S10_BUTTON,
125 SM5502_MUIC_ADC_REMOTE_S11_BUTTON,
126 SM5502_MUIC_ADC_REMOTE_S12_BUTTON,
127 SM5502_MUIC_ADC_RESERVED_ACC_1,
128 SM5502_MUIC_ADC_RESERVED_ACC_2,
129 SM5502_MUIC_ADC_RESERVED_ACC_3,
130 SM5502_MUIC_ADC_RESERVED_ACC_4,
131 SM5502_MUIC_ADC_RESERVED_ACC_5,
132 SM5502_MUIC_ADC_AUDIO_TYPE2,
133 SM5502_MUIC_ADC_PHONE_POWERED_DEV,
134 SM5502_MUIC_ADC_TTY_CONVERTER,
135 SM5502_MUIC_ADC_UART_CABLE,
136 SM5502_MUIC_ADC_TYPE1_CHARGER,
137 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_USB,
138 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_USB,
139 SM5502_MUIC_ADC_AUDIO_VIDEO_CABLE,
140 SM5502_MUIC_ADC_TYPE2_CHARGER,
141 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_UART,
142 SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_UART,
143 SM5502_MUIC_ADC_AUDIO_TYPE1,
144 SM5502_MUIC_ADC_OPEN = 0x1f,
146 /* The below accessories have same ADC value (0x1f or 0x1e).
147 So, Device type1 is used to separate specific accessory. */
148 /* |---------|--ADC| */
150 SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE = 0x3e, /* | 001|11110| */
151 SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END = 0x5e, /* | 010|11110| */
152 /* |Dev Type1|--ADC| */
153 SM5502_MUIC_ADC_OPEN_USB = 0x5f, /* | 010|11111| */
154 SM5502_MUIC_ADC_OPEN_TA = 0xdf, /* | 110|11111| */
155 SM5502_MUIC_ADC_OPEN_USB_OTG = 0xff, /* | 111|11111| */
158 /* List of supported interrupt for SM5502 */
159 static struct muic_irq sm5502_muic_irqs[] = {
160 { SM5502_IRQ_INT1_ATTACH, "muic-attach" },
161 { SM5502_IRQ_INT1_DETACH, "muic-detach" },
162 { SM5502_IRQ_INT1_KP, "muic-kp" },
163 { SM5502_IRQ_INT1_LKP, "muic-lkp" },
164 { SM5502_IRQ_INT1_LKR, "muic-lkr" },
165 { SM5502_IRQ_INT1_OVP_EVENT, "muic-ovp-event" },
166 { SM5502_IRQ_INT1_OCP_EVENT, "muic-ocp-event" },
167 { SM5502_IRQ_INT1_OVP_OCP_DIS, "muic-ovp-ocp-dis" },
168 { SM5502_IRQ_INT2_VBUS_DET, "muic-vbus-det" },
169 { SM5502_IRQ_INT2_REV_ACCE, "muic-rev-acce" },
170 { SM5502_IRQ_INT2_ADC_CHG, "muic-adc-chg" },
171 { SM5502_IRQ_INT2_STUCK_KEY, "muic-stuck-key" },
172 { SM5502_IRQ_INT2_STUCK_KEY_RCV, "muic-stuck-key-rcv" },
173 { SM5502_IRQ_INT2_MHL, "muic-mhl" },
176 /* Define interrupt list of SM5502 to register regmap_irq */
177 static const struct regmap_irq sm5502_irqs[] = {
178 /* INT1 interrupts */
179 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_ATTACH_MASK, },
180 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_DETACH_MASK, },
181 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_KP_MASK, },
182 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_LKP_MASK, },
183 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_LKR_MASK, },
184 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_OVP_EVENT_MASK, },
185 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_OCP_EVENT_MASK, },
186 { .reg_offset = 0, .mask = SM5502_IRQ_INT1_OVP_OCP_DIS_MASK, },
188 /* INT2 interrupts */
189 { .reg_offset = 1, .mask = SM5502_IRQ_INT2_VBUS_DET_MASK,},
190 { .reg_offset = 1, .mask = SM5502_IRQ_INT2_REV_ACCE_MASK, },
191 { .reg_offset = 1, .mask = SM5502_IRQ_INT2_ADC_CHG_MASK, },
192 { .reg_offset = 1, .mask = SM5502_IRQ_INT2_STUCK_KEY_MASK, },
193 { .reg_offset = 1, .mask = SM5502_IRQ_INT2_STUCK_KEY_RCV_MASK, },
194 { .reg_offset = 1, .mask = SM5502_IRQ_INT2_MHL_MASK, },
197 static const struct regmap_irq_chip sm5502_muic_irq_chip = {
199 .status_base = SM5502_REG_INT1,
200 .mask_base = SM5502_REG_INTMASK1,
201 .mask_invert = false,
204 .num_irqs = ARRAY_SIZE(sm5502_irqs),
207 /* Define regmap configuration of SM5502 for I2C communication */
208 static bool sm5502_muic_volatile_reg(struct device *dev, unsigned int reg)
211 case SM5502_REG_INTMASK1:
212 case SM5502_REG_INTMASK2:
220 static const struct regmap_config sm5502_muic_regmap_config = {
223 .volatile_reg = sm5502_muic_volatile_reg,
224 .max_register = SM5502_REG_END,
227 /* Change DM_CON/DP_CON/VBUSIN switch according to cable type */
228 static int sm5502_muic_set_path(struct sm5502_muic_info *info,
229 unsigned int con_sw, unsigned int vbus_sw,
235 con_sw = DM_DP_SWITCH_OPEN;
236 vbus_sw = VBUSIN_SWITCH_OPEN;
240 case DM_DP_SWITCH_OPEN:
241 case DM_DP_SWITCH_USB:
242 case DM_DP_SWITCH_AUDIO:
243 case DM_DP_SWITCH_UART:
244 ret = regmap_update_bits(info->regmap, SM5502_REG_MANUAL_SW1,
245 SM5502_REG_MANUAL_SW1_DP_MASK |
246 SM5502_REG_MANUAL_SW1_DM_MASK,
250 "cannot update DM_CON/DP_CON switch\n");
255 dev_err(info->dev, "Unknown DM_CON/DP_CON switch type (%d)\n",
261 case VBUSIN_SWITCH_OPEN:
262 case VBUSIN_SWITCH_VBUSOUT:
263 case VBUSIN_SWITCH_MIC:
264 case VBUSIN_SWITCH_VBUSOUT_WITH_USB:
265 ret = regmap_update_bits(info->regmap, SM5502_REG_MANUAL_SW1,
266 SM5502_REG_MANUAL_SW1_VBUSIN_MASK,
270 "cannot update VBUSIN switch\n");
275 dev_err(info->dev, "Unknown VBUS switch type (%d)\n", vbus_sw);
282 /* Return cable type of attached or detached accessories */
283 static unsigned int sm5502_muic_get_cable_type(struct sm5502_muic_info *info)
285 unsigned int cable_type = -1, adc, dev_type1;
288 /* Read ADC value according to external cable or button */
289 ret = regmap_read(info->regmap, SM5502_REG_ADC, &adc);
291 dev_err(info->dev, "failed to read ADC register\n");
296 * If ADC is SM5502_MUIC_ADC_GROUND(0x0), external cable hasn't
297 * connected with to MUIC device.
299 cable_type = adc & SM5502_REG_ADC_MASK;
300 if (cable_type == SM5502_MUIC_ADC_GROUND)
301 return SM5502_MUIC_ADC_GROUND;
303 switch (cable_type) {
304 case SM5502_MUIC_ADC_GROUND:
305 case SM5502_MUIC_ADC_SEND_END_BUTTON:
306 case SM5502_MUIC_ADC_REMOTE_S1_BUTTON:
307 case SM5502_MUIC_ADC_REMOTE_S2_BUTTON:
308 case SM5502_MUIC_ADC_REMOTE_S3_BUTTON:
309 case SM5502_MUIC_ADC_REMOTE_S4_BUTTON:
310 case SM5502_MUIC_ADC_REMOTE_S5_BUTTON:
311 case SM5502_MUIC_ADC_REMOTE_S6_BUTTON:
312 case SM5502_MUIC_ADC_REMOTE_S7_BUTTON:
313 case SM5502_MUIC_ADC_REMOTE_S8_BUTTON:
314 case SM5502_MUIC_ADC_REMOTE_S9_BUTTON:
315 case SM5502_MUIC_ADC_REMOTE_S10_BUTTON:
316 case SM5502_MUIC_ADC_REMOTE_S11_BUTTON:
317 case SM5502_MUIC_ADC_REMOTE_S12_BUTTON:
318 case SM5502_MUIC_ADC_RESERVED_ACC_1:
319 case SM5502_MUIC_ADC_RESERVED_ACC_2:
320 case SM5502_MUIC_ADC_RESERVED_ACC_3:
321 case SM5502_MUIC_ADC_RESERVED_ACC_4:
322 case SM5502_MUIC_ADC_RESERVED_ACC_5:
323 case SM5502_MUIC_ADC_AUDIO_TYPE2:
324 case SM5502_MUIC_ADC_PHONE_POWERED_DEV:
325 case SM5502_MUIC_ADC_TTY_CONVERTER:
326 case SM5502_MUIC_ADC_UART_CABLE:
327 case SM5502_MUIC_ADC_TYPE1_CHARGER:
328 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_USB:
329 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_USB:
330 case SM5502_MUIC_ADC_AUDIO_VIDEO_CABLE:
331 case SM5502_MUIC_ADC_TYPE2_CHARGER:
332 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_OFF_UART:
333 case SM5502_MUIC_ADC_FACTORY_MODE_BOOT_ON_UART:
335 case SM5502_MUIC_ADC_AUDIO_TYPE1:
337 * Check whether cable type is
338 * SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE
339 * or SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END
340 * by using Button event.
343 case SM5502_MUIC_ADC_OPEN:
344 ret = regmap_read(info->regmap, SM5502_REG_DEV_TYPE1,
347 dev_err(info->dev, "failed to read DEV_TYPE1 reg\n");
352 case SM5502_REG_DEV_TYPE1_USB_SDP_MASK:
353 cable_type = SM5502_MUIC_ADC_OPEN_USB;
355 case SM5502_REG_DEV_TYPE1_DEDICATED_CHG_MASK:
356 cable_type = SM5502_MUIC_ADC_OPEN_TA;
358 case SM5502_REG_DEV_TYPE1_USB_OTG_MASK:
359 cable_type = SM5502_MUIC_ADC_OPEN_USB_OTG;
363 "cannot identify the cable type: adc(0x%x) "
364 "dev_type1(0x%x)\n", adc, dev_type1);
370 "failed to identify the cable type: adc(0x%x)\n", adc);
377 static int sm5502_muic_cable_handler(struct sm5502_muic_info *info,
380 static unsigned int prev_cable_type = SM5502_MUIC_ADC_GROUND;
381 const char **cable_names = info->edev->supported_cable;
382 unsigned int cable_type = SM5502_MUIC_ADC_GROUND;
383 unsigned int con_sw = DM_DP_SWITCH_OPEN;
384 unsigned int vbus_sw = VBUSIN_SWITCH_OPEN;
385 unsigned int idx = 0;
391 /* Get the type of attached or detached cable */
393 cable_type = sm5502_muic_get_cable_type(info);
395 cable_type = prev_cable_type;
396 prev_cable_type = cable_type;
398 switch (cable_type) {
399 case SM5502_MUIC_ADC_OPEN_USB:
400 idx = EXTCON_CABLE_USB;
401 con_sw = DM_DP_SWITCH_USB;
402 vbus_sw = VBUSIN_SWITCH_VBUSOUT_WITH_USB;
404 case SM5502_MUIC_ADC_OPEN_TA:
405 idx = EXTCON_CABLE_TA;
406 con_sw = DM_DP_SWITCH_OPEN;
407 vbus_sw = VBUSIN_SWITCH_VBUSOUT;
409 case SM5502_MUIC_ADC_OPEN_USB_OTG:
410 idx = EXTCON_CABLE_USB_HOST;
411 con_sw = DM_DP_SWITCH_USB;
412 vbus_sw = VBUSIN_SWITCH_OPEN;
416 "cannot handle this cable_type (0x%x)\n", cable_type);
420 /* Change internal hardware path(DM_CON/DP_CON, VBUSIN) */
421 ret = sm5502_muic_set_path(info, con_sw, vbus_sw, attached);
425 /* Change the state of external accessory */
426 extcon_set_cable_state(info->edev, cable_names[idx], attached);
431 static void sm5502_muic_irq_work(struct work_struct *work)
433 struct sm5502_muic_info *info = container_of(work,
434 struct sm5502_muic_info, irq_work);
440 mutex_lock(&info->mutex);
442 /* Detect attached or detached cables */
443 if (info->irq_attach) {
444 ret = sm5502_muic_cable_handler(info, true);
445 info->irq_attach = false;
447 if (info->irq_detach) {
448 ret = sm5502_muic_cable_handler(info, false);
449 info->irq_detach = false;
453 dev_err(info->dev, "failed to handle MUIC interrupt\n");
455 mutex_unlock(&info->mutex);
459 * Sets irq_attach or irq_detach in sm5502_muic_info and returns 0.
460 * Returns -ESRCH if irq_type does not match registered IRQ for this dev type.
462 static int sm5502_parse_irq(struct sm5502_muic_info *info, int irq_type)
465 case SM5502_IRQ_INT1_ATTACH:
466 info->irq_attach = true;
468 case SM5502_IRQ_INT1_DETACH:
469 info->irq_detach = true;
471 case SM5502_IRQ_INT1_KP:
472 case SM5502_IRQ_INT1_LKP:
473 case SM5502_IRQ_INT1_LKR:
474 case SM5502_IRQ_INT1_OVP_EVENT:
475 case SM5502_IRQ_INT1_OCP_EVENT:
476 case SM5502_IRQ_INT1_OVP_OCP_DIS:
477 case SM5502_IRQ_INT2_VBUS_DET:
478 case SM5502_IRQ_INT2_REV_ACCE:
479 case SM5502_IRQ_INT2_ADC_CHG:
480 case SM5502_IRQ_INT2_STUCK_KEY:
481 case SM5502_IRQ_INT2_STUCK_KEY_RCV:
482 case SM5502_IRQ_INT2_MHL:
490 static irqreturn_t sm5502_muic_irq_handler(int irq, void *data)
492 struct sm5502_muic_info *info = data;
493 int i, irq_type = -1, ret;
495 for (i = 0; i < info->num_muic_irqs; i++)
496 if (irq == info->muic_irqs[i].virq)
497 irq_type = info->muic_irqs[i].irq;
499 ret = sm5502_parse_irq(info, irq_type);
501 dev_warn(info->dev, "cannot handle is interrupt:%d\n",
505 schedule_work(&info->irq_work);
510 static void sm5502_muic_detect_cable_wq(struct work_struct *work)
512 struct sm5502_muic_info *info = container_of(to_delayed_work(work),
513 struct sm5502_muic_info, wq_detcable);
516 /* Notify the state of connector cable or not */
517 ret = sm5502_muic_cable_handler(info, true);
519 dev_warn(info->dev, "failed to detect cable state\n");
522 static void sm5502_init_dev_type(struct sm5502_muic_info *info)
524 unsigned int reg_data, vendor_id, version_id;
527 /* To test I2C, Print version_id and vendor_id of SM5502 */
528 ret = regmap_read(info->regmap, SM5502_REG_DEVICE_ID, ®_data);
531 "failed to read DEVICE_ID register: %d\n", ret);
535 vendor_id = ((reg_data & SM5502_REG_DEVICE_ID_VENDOR_MASK) >>
536 SM5502_REG_DEVICE_ID_VENDOR_SHIFT);
537 version_id = ((reg_data & SM5502_REG_DEVICE_ID_VERSION_MASK) >>
538 SM5502_REG_DEVICE_ID_VERSION_SHIFT);
540 dev_info(info->dev, "Device type: version: 0x%x, vendor: 0x%x\n",
541 version_id, vendor_id);
543 /* Initiazle the register of SM5502 device to bring-up */
544 for (i = 0; i < info->num_reg_data; i++) {
545 unsigned int val = 0;
547 if (!info->reg_data[i].invert)
548 val |= ~info->reg_data[i].val;
550 val = info->reg_data[i].val;
551 regmap_write(info->regmap, info->reg_data[i].reg, val);
555 static int sm5022_muic_i2c_probe(struct i2c_client *i2c,
556 const struct i2c_device_id *id)
558 struct device_node *np = i2c->dev.of_node;
559 struct sm5502_muic_info *info;
560 int i, ret, irq_flags;
565 info = devm_kzalloc(&i2c->dev, sizeof(*info), GFP_KERNEL);
568 i2c_set_clientdata(i2c, info);
570 info->dev = &i2c->dev;
572 info->irq = i2c->irq;
573 info->muic_irqs = sm5502_muic_irqs;
574 info->num_muic_irqs = ARRAY_SIZE(sm5502_muic_irqs);
575 info->reg_data = sm5502_reg_data;
576 info->num_reg_data = ARRAY_SIZE(sm5502_reg_data);
578 mutex_init(&info->mutex);
580 INIT_WORK(&info->irq_work, sm5502_muic_irq_work);
582 info->regmap = devm_regmap_init_i2c(i2c, &sm5502_muic_regmap_config);
583 if (IS_ERR(info->regmap)) {
584 ret = PTR_ERR(info->regmap);
585 dev_err(info->dev, "failed to allocate register map: %d\n",
590 /* Support irq domain for SM5502 MUIC device */
591 irq_flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED;
592 ret = regmap_add_irq_chip(info->regmap, info->irq, irq_flags, 0,
593 &sm5502_muic_irq_chip, &info->irq_data);
595 dev_err(info->dev, "failed to request IRQ %d: %d\n",
600 for (i = 0; i < info->num_muic_irqs; i++) {
601 struct muic_irq *muic_irq = &info->muic_irqs[i];
602 unsigned int virq = 0;
604 virq = regmap_irq_get_virq(info->irq_data, muic_irq->irq);
607 muic_irq->virq = virq;
609 ret = devm_request_threaded_irq(info->dev, virq, NULL,
610 sm5502_muic_irq_handler,
612 muic_irq->name, info);
615 "failed: irq request (IRQ: %d, error :%d)\n",
621 /* Allocate extcon device */
622 info->edev = devm_extcon_dev_allocate(info->dev, sm5502_extcon_cable);
623 if (IS_ERR(info->edev)) {
624 dev_err(info->dev, "failed to allocate memory for extcon\n");
627 info->edev->name = np->name;
629 /* Register extcon device */
630 ret = devm_extcon_dev_register(info->dev, info->edev);
632 dev_err(info->dev, "failed to register extcon device\n");
637 * Detect accessory after completing the initialization of platform
639 * - Use delayed workqueue to detect cable state and then
640 * notify cable state to notifiee/platform through uevent.
641 * After completing the booting of platform, the extcon provider
642 * driver should notify cable state to upper layer.
644 INIT_DELAYED_WORK(&info->wq_detcable, sm5502_muic_detect_cable_wq);
645 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
646 msecs_to_jiffies(DELAY_MS_DEFAULT));
648 /* Initialize SM5502 device and print vendor id and version id */
649 sm5502_init_dev_type(info);
654 static int sm5502_muic_i2c_remove(struct i2c_client *i2c)
656 struct sm5502_muic_info *info = i2c_get_clientdata(i2c);
658 regmap_del_irq_chip(info->irq, info->irq_data);
663 static struct of_device_id sm5502_dt_match[] = {
664 { .compatible = "siliconmitus,sm5502-muic" },
668 #ifdef CONFIG_PM_SLEEP
669 static int sm5502_muic_suspend(struct device *dev)
671 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
672 struct sm5502_muic_info *info = i2c_get_clientdata(i2c);
674 enable_irq_wake(info->irq);
679 static int sm5502_muic_resume(struct device *dev)
681 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
682 struct sm5502_muic_info *info = i2c_get_clientdata(i2c);
684 disable_irq_wake(info->irq);
690 static SIMPLE_DEV_PM_OPS(sm5502_muic_pm_ops,
691 sm5502_muic_suspend, sm5502_muic_resume);
693 static const struct i2c_device_id sm5502_i2c_id[] = {
694 { "sm5502", TYPE_SM5502 },
697 MODULE_DEVICE_TABLE(i2c, sm5502_i2c_id);
699 static struct i2c_driver sm5502_muic_i2c_driver = {
702 .owner = THIS_MODULE,
703 .pm = &sm5502_muic_pm_ops,
704 .of_match_table = sm5502_dt_match,
706 .probe = sm5022_muic_i2c_probe,
707 .remove = sm5502_muic_i2c_remove,
708 .id_table = sm5502_i2c_id,
711 static int __init sm5502_muic_i2c_init(void)
713 return i2c_add_driver(&sm5502_muic_i2c_driver);
715 subsys_initcall(sm5502_muic_i2c_init);
717 MODULE_DESCRIPTION("Silicon Mitus SM5502 Extcon driver");
718 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
719 MODULE_LICENSE("GPL");