fiq_debugger: merge from linux 3.10
[firefly-linux-kernel-4.4.55.git] / drivers / extcon / extcon.c
1 /*
2  *  drivers/extcon/extcon.c - External Connector (extcon) framework.
3  *
4  *  External connector (extcon) class driver
5  *
6  * Copyright (C) 2015 Samsung Electronics
7  * Author: Chanwoo Choi <cw00.choi@samsung.com>
8  *
9  * Copyright (C) 2012 Samsung Electronics
10  * Author: Donggeun Kim <dg77.kim@samsung.com>
11  * Author: MyungJoo Ham <myungjoo.ham@samsung.com>
12  *
13  * based on android/drivers/switch/switch_class.c
14  * Copyright (C) 2008 Google, Inc.
15  * Author: Mike Lockwood <lockwood@android.com>
16  *
17  * This software is licensed under the terms of the GNU General Public
18  * License version 2, as published by the Free Software Foundation, and
19  * may be copied, distributed, and modified under those terms.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  */
26
27 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/init.h>
30 #include <linux/device.h>
31 #include <linux/fs.h>
32 #include <linux/err.h>
33 #include <linux/extcon.h>
34 #include <linux/of.h>
35 #include <linux/slab.h>
36 #include <linux/sysfs.h>
37
38 #define SUPPORTED_CABLE_MAX     32
39 #define CABLE_NAME_MAX          30
40
41 struct __extcon_info {
42         unsigned int type;
43         unsigned int id;
44         const char *name;
45
46 } extcon_info[] = {
47         [EXTCON_NONE] = {
48                 .type = EXTCON_TYPE_MISC,
49                 .id = EXTCON_NONE,
50                 .name = "NONE",
51         },
52
53         /* USB external connector */
54         [EXTCON_USB] = {
55                 .type = EXTCON_TYPE_USB,
56                 .id = EXTCON_USB,
57                 .name = "USB",
58         },
59         [EXTCON_USB_HOST] = {
60                 .type = EXTCON_TYPE_USB,
61                 .id = EXTCON_USB_HOST,
62                 .name = "USB_HOST",
63         },
64         [EXTCON_USB_VBUS_EN] = {
65                 .type = EXTCON_TYPE_USB,
66                 .id = EXTCON_USB_VBUS_EN,
67                 .name = "USB_VBUS_EN",
68         },
69
70         /* Charging external connector */
71         [EXTCON_CHG_USB_SDP] = {
72                 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
73                 .id = EXTCON_CHG_USB_SDP,
74                 .name = "SDP",
75         },
76         [EXTCON_CHG_USB_DCP] = {
77                 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
78                 .id = EXTCON_CHG_USB_DCP,
79                 .name = "DCP",
80         },
81         [EXTCON_CHG_USB_CDP] = {
82                 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
83                 .id = EXTCON_CHG_USB_CDP,
84                 .name = "CDP",
85         },
86         [EXTCON_CHG_USB_ACA] = {
87                 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
88                 .id = EXTCON_CHG_USB_ACA,
89                 .name = "ACA",
90         },
91         [EXTCON_CHG_USB_FAST] = {
92                 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
93                 .id = EXTCON_CHG_USB_FAST,
94                 .name = "FAST-CHARGER",
95         },
96         [EXTCON_CHG_USB_SLOW] = {
97                 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
98                 .id = EXTCON_CHG_USB_SLOW,
99                 .name = "SLOW-CHARGER",
100         },
101
102         /* Jack external connector */
103         [EXTCON_JACK_MICROPHONE] = {
104                 .type = EXTCON_TYPE_JACK,
105                 .id = EXTCON_JACK_MICROPHONE,
106                 .name = "MICROPHONE",
107         },
108         [EXTCON_JACK_HEADPHONE] = {
109                 .type = EXTCON_TYPE_JACK,
110                 .id = EXTCON_JACK_HEADPHONE,
111                 .name = "HEADPHONE",
112         },
113         [EXTCON_JACK_LINE_IN] = {
114                 .type = EXTCON_TYPE_JACK,
115                 .id = EXTCON_JACK_LINE_IN,
116                 .name = "LINE-IN",
117         },
118         [EXTCON_JACK_LINE_OUT] = {
119                 .type = EXTCON_TYPE_JACK,
120                 .id = EXTCON_JACK_LINE_OUT,
121                 .name = "LINE-OUT",
122         },
123         [EXTCON_JACK_VIDEO_IN] = {
124                 .type = EXTCON_TYPE_JACK,
125                 .id = EXTCON_JACK_VIDEO_IN,
126                 .name = "VIDEO-IN",
127         },
128         [EXTCON_JACK_VIDEO_OUT] = {
129                 .type = EXTCON_TYPE_JACK,
130                 .id = EXTCON_JACK_VIDEO_OUT,
131                 .name = "VIDEO-OUT",
132         },
133         [EXTCON_JACK_SPDIF_IN] = {
134                 .type = EXTCON_TYPE_JACK,
135                 .id = EXTCON_JACK_SPDIF_IN,
136                 .name = "SPDIF-IN",
137         },
138         [EXTCON_JACK_SPDIF_OUT] = {
139                 .type = EXTCON_TYPE_JACK,
140                 .id = EXTCON_JACK_SPDIF_OUT,
141                 .name = "SPDIF-OUT",
142         },
143
144         /* Display external connector */
145         [EXTCON_DISP_HDMI] = {
146                 .type = EXTCON_TYPE_DISP,
147                 .id = EXTCON_DISP_HDMI,
148                 .name = "HDMI",
149         },
150         [EXTCON_DISP_MHL] = {
151                 .type = EXTCON_TYPE_DISP,
152                 .id = EXTCON_DISP_MHL,
153                 .name = "MHL",
154         },
155         [EXTCON_DISP_DVI] = {
156                 .type = EXTCON_TYPE_DISP,
157                 .id = EXTCON_DISP_DVI,
158                 .name = "DVI",
159         },
160         [EXTCON_DISP_VGA] = {
161                 .type = EXTCON_TYPE_DISP,
162                 .id = EXTCON_DISP_VGA,
163                 .name = "VGA",
164         },
165         [EXTCON_DISP_DP] = {
166                 .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB,
167                 .id = EXTCON_DISP_DP,
168                 .name = "DP",
169         },
170
171         /* Miscellaneous external connector */
172         [EXTCON_DOCK] = {
173                 .type = EXTCON_TYPE_MISC,
174                 .id = EXTCON_DOCK,
175                 .name = "DOCK",
176         },
177         [EXTCON_JIG] = {
178                 .type = EXTCON_TYPE_MISC,
179                 .id = EXTCON_JIG,
180                 .name = "JIG",
181         },
182         [EXTCON_MECHANICAL] = {
183                 .type = EXTCON_TYPE_MISC,
184                 .id = EXTCON_MECHANICAL,
185                 .name = "MECHANICAL",
186         },
187
188         { /* sentinel */ }
189 };
190
191 /**
192  * struct extcon_cable - An internal data for each cable of extcon device.
193  * @edev:               The extcon device
194  * @cable_index:        Index of this cable in the edev
195  * @attr_g:             Attribute group for the cable
196  * @attr_name:          "name" sysfs entry
197  * @attr_state:         "state" sysfs entry
198  * @attrs:              Array pointing to attr_name and attr_state for attr_g
199  */
200 struct extcon_cable {
201         struct extcon_dev *edev;
202         int cable_index;
203
204         struct attribute_group attr_g;
205         struct device_attribute attr_name;
206         struct device_attribute attr_state;
207
208         struct attribute *attrs[3]; /* to be fed to attr_g.attrs */
209
210         union extcon_property_value usb_propval[EXTCON_PROP_USB_CNT];
211         union extcon_property_value chg_propval[EXTCON_PROP_CHG_CNT];
212         union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT];
213         union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT];
214
215         unsigned long usb_bits[BITS_TO_LONGS(EXTCON_PROP_USB_CNT)];
216         unsigned long chg_bits[BITS_TO_LONGS(EXTCON_PROP_CHG_CNT)];
217         unsigned long jack_bits[BITS_TO_LONGS(EXTCON_PROP_JACK_CNT)];
218         unsigned long disp_bits[BITS_TO_LONGS(EXTCON_PROP_DISP_CNT)];
219 };
220
221 static struct class *extcon_class;
222 #if defined(CONFIG_ANDROID)
223 static struct class_compat *switch_class;
224 #endif /* CONFIG_ANDROID */
225
226 static LIST_HEAD(extcon_dev_list);
227 static DEFINE_MUTEX(extcon_dev_list_lock);
228
229 /**
230  * check_mutually_exclusive - Check if new_state violates mutually_exclusive
231  *                            condition.
232  * @edev:       the extcon device
233  * @new_state:  new cable attach status for @edev
234  *
235  * Returns 0 if nothing violates. Returns the index + 1 for the first
236  * violated condition.
237  */
238 static int check_mutually_exclusive(struct extcon_dev *edev, u32 new_state)
239 {
240         int i = 0;
241
242         if (!edev->mutually_exclusive)
243                 return 0;
244
245         for (i = 0; edev->mutually_exclusive[i]; i++) {
246                 int weight;
247                 u32 correspondants = new_state & edev->mutually_exclusive[i];
248
249                 /* calculate the total number of bits set */
250                 weight = hweight32(correspondants);
251                 if (weight > 1)
252                         return i + 1;
253         }
254
255         return 0;
256 }
257
258 static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id)
259 {
260         int i;
261
262         /* Find the the index of extcon cable in edev->supported_cable */
263         for (i = 0; i < edev->max_supported; i++) {
264                 if (edev->supported_cable[i] == id)
265                         return i;
266         }
267
268         return -EINVAL;
269 }
270
271 static int get_extcon_type(unsigned int prop)
272 {
273         switch (prop) {
274         case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX:
275                 return EXTCON_TYPE_USB;
276         case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX:
277                 return EXTCON_TYPE_CHG;
278         case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX:
279                 return EXTCON_TYPE_JACK;
280         case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX:
281                 return EXTCON_TYPE_DISP;
282         default:
283                 return -EINVAL;
284         }
285 }
286
287 static bool is_extcon_attached(struct extcon_dev *edev, unsigned int index)
288 {
289         return !!(edev->state & BIT(index));
290 }
291
292 static bool is_extcon_changed(struct extcon_dev *edev, int index,
293                                 bool new_state)
294 {
295         int state = !!(edev->state & BIT(index));
296         return (state != new_state);
297 }
298
299 static bool is_extcon_property_supported(unsigned int id, unsigned int prop)
300 {
301         int type;
302
303         /* Check whether the property is supported or not. */
304         type = get_extcon_type(prop);
305         if (type < 0)
306                 return false;
307
308         /* Check whether a specific extcon id supports the property or not. */
309         return !!(extcon_info[id].type & type);
310 }
311
312 static int is_extcon_property_capability(struct extcon_dev *edev,
313                                 unsigned int id, int index,unsigned int prop)
314 {
315         struct extcon_cable *cable;
316         int type, ret;
317
318         /* Check whether the property is supported or not. */
319         type = get_extcon_type(prop);
320         if (type < 0)
321                 return type;
322
323         cable = &edev->cables[index];
324
325         switch (type) {
326         case EXTCON_TYPE_USB:
327                 ret = test_bit(prop - EXTCON_PROP_USB_MIN, cable->usb_bits);
328                 break;
329         case EXTCON_TYPE_CHG:
330                 ret = test_bit(prop - EXTCON_PROP_CHG_MIN, cable->chg_bits);
331                 break;
332         case EXTCON_TYPE_JACK:
333                 ret = test_bit(prop - EXTCON_PROP_JACK_MIN, cable->jack_bits);
334                 break;
335         case EXTCON_TYPE_DISP:
336                 ret = test_bit(prop - EXTCON_PROP_DISP_MIN, cable->disp_bits);
337                 break;
338         default:
339                 ret = -EINVAL;
340         }
341
342         return ret;
343 }
344
345 static void init_property(struct extcon_dev *edev, unsigned int id, int index)
346 {
347         unsigned int type = extcon_info[id].type;
348         struct extcon_cable *cable = &edev->cables[index];
349
350         if (EXTCON_TYPE_USB & type)
351                 memset(cable->usb_propval, 0, sizeof(cable->usb_propval));
352         if (EXTCON_TYPE_CHG & type)
353                 memset(cable->chg_propval, 0, sizeof(cable->chg_propval));
354         if (EXTCON_TYPE_JACK & type)
355                 memset(cable->jack_propval, 0, sizeof(cable->jack_propval));
356         if (EXTCON_TYPE_DISP & type)
357                 memset(cable->disp_propval, 0, sizeof(cable->disp_propval));
358 }
359
360 static ssize_t state_show(struct device *dev, struct device_attribute *attr,
361                           char *buf)
362 {
363         int i, count = 0;
364         struct extcon_dev *edev = dev_get_drvdata(dev);
365
366         if (edev->max_supported == 0)
367                 return sprintf(buf, "%u\n", edev->state);
368
369         for (i = 0; i < edev->max_supported; i++) {
370                 count += sprintf(buf + count, "%s=%d\n",
371                                 extcon_info[edev->supported_cable[i]].name,
372                                  !!(edev->state & (1 << i)));
373         }
374
375         return count;
376 }
377 static DEVICE_ATTR_RO(state);
378
379 static ssize_t name_show(struct device *dev, struct device_attribute *attr,
380                 char *buf)
381 {
382         struct extcon_dev *edev = dev_get_drvdata(dev);
383
384         return sprintf(buf, "%s\n", edev->name);
385 }
386 static DEVICE_ATTR_RO(name);
387
388 static ssize_t cable_name_show(struct device *dev,
389                                struct device_attribute *attr, char *buf)
390 {
391         struct extcon_cable *cable = container_of(attr, struct extcon_cable,
392                                                   attr_name);
393         int i = cable->cable_index;
394
395         return sprintf(buf, "%s\n",
396                         extcon_info[cable->edev->supported_cable[i]].name);
397 }
398
399 static ssize_t cable_state_show(struct device *dev,
400                                 struct device_attribute *attr, char *buf)
401 {
402         struct extcon_cable *cable = container_of(attr, struct extcon_cable,
403                                                   attr_state);
404
405         int i = cable->cable_index;
406
407         return sprintf(buf, "%d\n",
408                 extcon_get_state(cable->edev, cable->edev->supported_cable[i]));
409 }
410
411 /**
412  * extcon_sync()        - Synchronize the states for both the attached/detached
413  * @edev:               the extcon device that has the cable.
414  *
415  * This function send a notification to synchronize the all states of a
416  * specific external connector
417  */
418 int extcon_sync(struct extcon_dev *edev, unsigned int id)
419 {
420         char name_buf[120];
421         char state_buf[120];
422         char *prop_buf;
423         char *envp[3];
424         int env_offset = 0;
425         int length;
426         int index;
427         int state;
428         unsigned long flags;
429
430         if (!edev)
431                 return -EINVAL;
432
433         index = find_cable_index_by_id(edev, id);
434         if (index < 0)
435                 return index;
436
437         spin_lock_irqsave(&edev->lock, flags);
438
439         state = !!(edev->state & BIT(index));
440         raw_notifier_call_chain(&edev->nh[index], state, edev);
441
442         /* This could be in interrupt handler */
443         prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
444         if (!prop_buf) {
445                 /* Unlock early before uevent */
446                 spin_unlock_irqrestore(&edev->lock, flags);
447
448                 dev_err(&edev->dev, "out of memory in extcon_set_state\n");
449                 kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE);
450
451                 return 0;
452         }
453
454         length = name_show(&edev->dev, NULL, prop_buf);
455         if (length > 0) {
456                 if (prop_buf[length - 1] == '\n')
457                         prop_buf[length - 1] = 0;
458                 snprintf(name_buf, sizeof(name_buf), "NAME=%s", prop_buf);
459                 envp[env_offset++] = name_buf;
460         }
461
462         length = state_show(&edev->dev, NULL, prop_buf);
463         if (length > 0) {
464                 if (prop_buf[length - 1] == '\n')
465                         prop_buf[length - 1] = 0;
466                 snprintf(state_buf, sizeof(state_buf), "STATE=%s", prop_buf);
467                 envp[env_offset++] = state_buf;
468         }
469         envp[env_offset] = NULL;
470
471         /* Unlock early before uevent */
472         spin_unlock_irqrestore(&edev->lock, flags);
473         kobject_uevent_env(&edev->dev.kobj, KOBJ_CHANGE, envp);
474         free_page((unsigned long)prop_buf);
475
476         return 0;
477 }
478 EXPORT_SYMBOL_GPL(extcon_sync);
479
480 /**
481  * extcon_get_state() - Get the state of a external connector.
482  * @edev:       the extcon device that has the cable.
483  * @id:         the unique id of each external connector in extcon enumeration.
484  */
485 int extcon_get_state(struct extcon_dev *edev, const unsigned int id)
486 {
487         int index, state;
488         unsigned long flags;
489
490         if (!edev)
491                 return -EINVAL;
492
493         index = find_cable_index_by_id(edev, id);
494         if (index < 0)
495                 return index;
496
497         spin_lock_irqsave(&edev->lock, flags);
498         state = is_extcon_attached(edev, index);
499         spin_unlock_irqrestore(&edev->lock, flags);
500
501         return state;
502 }
503 EXPORT_SYMBOL_GPL(extcon_get_state);
504
505 /**
506  * extcon_set_state() - Set the state of a external connector.
507  *                      without a notification.
508  * @edev:               the extcon device that has the cable.
509  * @id:                 the unique id of each external connector
510  *                      in extcon enumeration.
511  * @state:              the new cable status. The default semantics is
512  *                      true: attached / false: detached.
513  *
514  * This function only set the state of a external connector without
515  * a notification. To synchronize the data of a external connector,
516  * use extcon_set_state_sync() and extcon_sync().
517  */
518 int extcon_set_state(struct extcon_dev *edev, unsigned int id,
519                                 bool cable_state)
520 {
521         unsigned long flags;
522         int index, ret = 0;
523
524         if (!edev)
525                 return -EINVAL;
526
527         index = find_cable_index_by_id(edev, id);
528         if (index < 0)
529                 return index;
530
531         spin_lock_irqsave(&edev->lock, flags);
532
533         /* Check whether the external connector's state is changed. */
534         if (!is_extcon_changed(edev, index, cable_state))
535                 goto out;
536
537         if (check_mutually_exclusive(edev,
538                 (edev->state & ~BIT(index)) | (cable_state & BIT(index)))) {
539                 ret = -EPERM;
540                 goto out;
541         }
542
543         /*
544          * Initialize the value of extcon property before setting
545          * the detached state for an external connector.
546          */
547         if (!cable_state)
548                 init_property(edev, id, index);
549
550         /* Update the state for a external connector. */
551         if (cable_state)
552                 edev->state |= BIT(index);
553         else
554                 edev->state &= ~(BIT(index));
555 out:
556         spin_unlock_irqrestore(&edev->lock, flags);
557
558         return ret;
559 }
560 EXPORT_SYMBOL_GPL(extcon_set_state);
561
562 /**
563  * extcon_set_state_sync() - Set the state of a external connector
564  *                      with a notification.
565  * @edev:               the extcon device that has the cable.
566  * @id:                 the unique id of each external connector
567  *                      in extcon enumeration.
568  * @state:              the new cable status. The default semantics is
569  *                      true: attached / false: detached.
570  *
571  * This function set the state of external connector and synchronize the data
572  * by usning a notification.
573  */
574 int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id,
575                                 bool cable_state)
576 {
577         int ret, index;
578         unsigned long flags;
579
580         index = find_cable_index_by_id(edev, id);
581         if (index < 0)
582                 return index;
583
584         /* Check whether the external connector's state is changed. */
585         spin_lock_irqsave(&edev->lock, flags);
586         ret = is_extcon_changed(edev, index, cable_state);
587         spin_unlock_irqrestore(&edev->lock, flags);
588         if (!ret)
589                 return 0;
590
591         ret = extcon_set_state(edev, id, cable_state);
592         if (ret < 0)
593                 return ret;
594
595         return extcon_sync(edev, id);
596 }
597 EXPORT_SYMBOL_GPL(extcon_set_state_sync);
598
599 /**
600  * extcon_get_property() - Get the property value of a specific cable.
601  * @edev:               the extcon device that has the cable.
602  * @id:                 the unique id of each external connector
603  *                      in extcon enumeration.
604  * @prop:               the property id among enum extcon_property.
605  * @prop_val:           the pointer which store the value of property.
606  *
607  * When getting the property value of external connector, the external connector
608  * should be attached. If detached state, function just return 0 without
609  * property value. Also, the each property should be included in the list of
610  * supported properties according to the type of external connectors.
611  *
612  * Returns 0 if success or error number if fail
613  */
614 int extcon_get_property(struct extcon_dev *edev, unsigned int id,
615                                 unsigned int prop,
616                                 union extcon_property_value *prop_val)
617 {
618         struct extcon_cable *cable;
619         unsigned long flags;
620         int index, ret = 0;
621
622         *prop_val = (union extcon_property_value)(0);
623
624         if (!edev)
625                 return -EINVAL;
626
627         /* Check whether the property is supported or not */
628         if (!is_extcon_property_supported(id, prop))
629                 return -EINVAL;
630
631         /* Find the cable index of external connector by using id */
632         index = find_cable_index_by_id(edev, id);
633         if (index < 0)
634                 return index;
635
636         spin_lock_irqsave(&edev->lock, flags);
637
638         /* Check whether the property is available or not. */
639         if (!is_extcon_property_capability(edev, id, index, prop)) {
640                 spin_unlock_irqrestore(&edev->lock, flags);
641                 return -EPERM;
642         }
643
644         /*
645          * Check whether the external connector is attached.
646          * If external connector is detached, the user can not
647          * get the property value.
648          */
649         if (!is_extcon_attached(edev, index)) {
650                 spin_unlock_irqrestore(&edev->lock, flags);
651                 return 0;
652         }
653
654         cable = &edev->cables[index];
655
656         /* Get the property value according to extcon type */
657         switch (prop) {
658         case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX:
659                 *prop_val = cable->usb_propval[prop - EXTCON_PROP_USB_MIN];
660                 break;
661         case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX:
662                 *prop_val = cable->chg_propval[prop - EXTCON_PROP_CHG_MIN];
663                 break;
664         case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX:
665                 *prop_val = cable->jack_propval[prop - EXTCON_PROP_JACK_MIN];
666                 break;
667         case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX:
668                 *prop_val = cable->disp_propval[prop - EXTCON_PROP_DISP_MIN];
669                 break;
670         default:
671                 ret = -EINVAL;
672                 break;
673         }
674
675         spin_unlock_irqrestore(&edev->lock, flags);
676
677         return ret;
678 }
679 EXPORT_SYMBOL_GPL(extcon_get_property);
680
681 /**
682  * extcon_set_property() - Set the property value of a specific cable.
683  * @edev:               the extcon device that has the cable.
684  * @id:                 the unique id of each external connector
685  *                      in extcon enumeration.
686  * @prop:               the property id among enum extcon_property.
687  * @prop_val:           the pointer including the new value of property.
688  *
689  * The each property should be included in the list of supported properties
690  * according to the type of external connectors.
691  *
692  * Returns 0 if success or error number if fail
693  */
694 int extcon_set_property(struct extcon_dev *edev, unsigned int id,
695                                 unsigned int prop,
696                                 union extcon_property_value prop_val)
697 {
698         struct extcon_cable *cable;
699         unsigned long flags;
700         int index, ret = 0;
701
702         if (!edev)
703                 return -EINVAL;
704
705         /* Check whether the property is supported or not */
706         if (!is_extcon_property_supported(id, prop))
707                 return -EINVAL;
708
709         /* Find the cable index of external connector by using id */
710         index = find_cable_index_by_id(edev, id);
711         if (index < 0)
712                 return index;
713
714         spin_lock_irqsave(&edev->lock, flags);
715
716         /* Check whether the property is available or not. */
717         if (!is_extcon_property_capability(edev, id, index, prop)) {
718                 spin_unlock_irqrestore(&edev->lock, flags);
719                 return -EPERM;
720         }
721
722         cable = &edev->cables[index];
723
724         /* Set the property value according to extcon type */
725         switch (prop) {
726         case EXTCON_PROP_USB_MIN ... EXTCON_PROP_USB_MAX:
727                 cable->usb_propval[prop - EXTCON_PROP_USB_MIN] = prop_val;
728                 break;
729         case EXTCON_PROP_CHG_MIN ... EXTCON_PROP_CHG_MAX:
730                 cable->chg_propval[prop - EXTCON_PROP_CHG_MIN] = prop_val;
731                 break;
732         case EXTCON_PROP_JACK_MIN ... EXTCON_PROP_JACK_MAX:
733                 cable->jack_propval[prop - EXTCON_PROP_JACK_MIN] = prop_val;
734                 break;
735         case EXTCON_PROP_DISP_MIN ... EXTCON_PROP_DISP_MAX:
736                 cable->disp_propval[prop - EXTCON_PROP_DISP_MIN] = prop_val;
737                 break;
738         default:
739                 ret = -EINVAL;
740                 break;
741         }
742
743         spin_unlock_irqrestore(&edev->lock, flags);
744
745         return ret;
746 }
747 EXPORT_SYMBOL_GPL(extcon_set_property);
748
749 /**
750  * extcon_set_property_sync() - Set the property value of a specific cable
751                         with a notification.
752  * @prop_val:           the pointer including the new value of property.
753  *
754  * When setting the property value of external connector, the external connector
755  * should be attached. The each property should be included in the list of
756  * supported properties according to the type of external connectors.
757  *
758  * Returns 0 if success or error number if fail
759  */
760 int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id,
761                                 unsigned int prop,
762                                 union extcon_property_value prop_val)
763 {
764         int ret;
765
766         ret = extcon_set_property(edev, id, prop, prop_val);
767         if (ret < 0)
768                 return ret;
769
770         return extcon_sync(edev, id);
771 }
772 EXPORT_SYMBOL_GPL(extcon_set_property_sync);
773
774 /**
775  * extcon_get_property_capability() - Get the capability of property
776  *                      of an external connector.
777  * @edev:               the extcon device that has the cable.
778  * @id:                 the unique id of each external connector
779  *                      in extcon enumeration.
780  * @prop:               the property id among enum extcon_property.
781  *
782  * Returns 1 if the property is available or 0 if not available.
783  */
784 int extcon_get_property_capability(struct extcon_dev *edev, unsigned int id,
785                                         unsigned int prop)
786 {
787         int index;
788
789         if (!edev)
790                 return -EINVAL;
791
792         /* Check whether the property is supported or not */
793         if (!is_extcon_property_supported(id, prop))
794                 return -EINVAL;
795
796         /* Find the cable index of external connector by using id */
797         index = find_cable_index_by_id(edev, id);
798         if (index < 0)
799                 return index;
800
801         return is_extcon_property_capability(edev, id, index, prop);
802 }
803 EXPORT_SYMBOL_GPL(extcon_get_property_capability);
804
805 /**
806  * extcon_set_property_capability() - Set the capability of a property
807  *                      of an external connector.
808  * @edev:               the extcon device that has the cable.
809  * @id:                 the unique id of each external connector
810  *                      in extcon enumeration.
811  * @prop:               the property id among enum extcon_property.
812  *
813  * This function set the capability of a property for an external connector
814  * to mark the bit in capability bitmap which mean the available state of
815  * a property.
816  *
817  * Returns 0 if success or error number if fail
818  */
819 int extcon_set_property_capability(struct extcon_dev *edev, unsigned int id,
820                                         unsigned int prop)
821 {
822         struct extcon_cable *cable;
823         int index, type, ret = 0;
824
825         if (!edev)
826                 return -EINVAL;
827
828         /* Check whether the property is supported or not. */
829         if (!is_extcon_property_supported(id, prop))
830                 return -EINVAL;
831
832         /* Find the cable index of external connector by using id. */
833         index = find_cable_index_by_id(edev, id);
834         if (index < 0)
835                 return index;
836
837         /* Check whether the property is supported or not. */
838         type = get_extcon_type(prop);
839         if (type < 0)
840                 return type;
841
842         cable = &edev->cables[index];
843
844         switch (type) {
845         case EXTCON_TYPE_USB:
846                 __set_bit(prop - EXTCON_PROP_USB_MIN, cable->usb_bits);
847                 break;
848         case EXTCON_TYPE_CHG:
849                 __set_bit(prop - EXTCON_PROP_CHG_MIN, cable->chg_bits);
850                 break;
851         case EXTCON_TYPE_JACK:
852                 __set_bit(prop - EXTCON_PROP_JACK_MIN, cable->jack_bits);
853                 break;
854         case EXTCON_TYPE_DISP:
855                 __set_bit(prop - EXTCON_PROP_DISP_MIN, cable->disp_bits);
856                 break;
857         default:
858                 ret = -EINVAL;
859         }
860
861         return ret;
862 }
863 EXPORT_SYMBOL_GPL(extcon_set_property_capability);
864
865 /**
866  * extcon_get_extcon_dev() - Get the extcon device instance from the name
867  * @extcon_name:        The extcon name provided with extcon_dev_register()
868  */
869 struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
870 {
871         struct extcon_dev *sd;
872
873         if (!extcon_name)
874                 return ERR_PTR(-EINVAL);
875
876         mutex_lock(&extcon_dev_list_lock);
877         list_for_each_entry(sd, &extcon_dev_list, entry) {
878                 if (!strcmp(sd->name, extcon_name))
879                         goto out;
880         }
881         sd = NULL;
882 out:
883         mutex_unlock(&extcon_dev_list_lock);
884         return sd;
885 }
886 EXPORT_SYMBOL_GPL(extcon_get_extcon_dev);
887
888 /**
889  * extcon_register_notifier() - Register a notifiee to get notified by
890  *                              any attach status changes from the extcon.
891  * @edev:       the extcon device that has the external connecotr.
892  * @id:         the unique id of each external connector in extcon enumeration.
893  * @nb:         a notifier block to be registered.
894  *
895  * Note that the second parameter given to the callback of nb (val) is
896  * "old_state", not the current state. The current state can be retrieved
897  * by looking at the third pameter (edev pointer)'s state value.
898  */
899 int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
900                              struct notifier_block *nb)
901 {
902         unsigned long flags;
903         int ret, idx;
904
905         if (!nb)
906                 return -EINVAL;
907
908         if (edev) {
909                 idx = find_cable_index_by_id(edev, id);
910                 if (idx < 0)
911                         return idx;
912
913                 spin_lock_irqsave(&edev->lock, flags);
914                 ret = raw_notifier_chain_register(&edev->nh[idx], nb);
915                 spin_unlock_irqrestore(&edev->lock, flags);
916         } else {
917                 struct extcon_dev *extd;
918
919                 mutex_lock(&extcon_dev_list_lock);
920                 list_for_each_entry(extd, &extcon_dev_list, entry) {
921                         idx = find_cable_index_by_id(extd, id);
922                         if (idx >= 0)
923                                 break;
924                 }
925                 mutex_unlock(&extcon_dev_list_lock);
926
927                 if (idx >= 0) {
928                         edev = extd;
929                         return extcon_register_notifier(extd, id, nb);
930                 } else {
931                         ret = -ENODEV;
932                 }
933         }
934
935         return ret;
936 }
937 EXPORT_SYMBOL_GPL(extcon_register_notifier);
938
939 /**
940  * extcon_unregister_notifier() - Unregister a notifiee from the extcon device.
941  * @edev:       the extcon device that has the external connecotr.
942  * @id:         the unique id of each external connector in extcon enumeration.
943  * @nb:         a notifier block to be registered.
944  */
945 int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
946                                 struct notifier_block *nb)
947 {
948         unsigned long flags;
949         int ret, idx;
950
951         if (!edev || !nb)
952                 return -EINVAL;
953
954         idx = find_cable_index_by_id(edev, id);
955         if (idx < 0)
956                 return idx;
957
958         spin_lock_irqsave(&edev->lock, flags);
959         ret = raw_notifier_chain_unregister(&edev->nh[idx], nb);
960         spin_unlock_irqrestore(&edev->lock, flags);
961
962         return ret;
963 }
964 EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
965
966 static struct attribute *extcon_attrs[] = {
967         &dev_attr_state.attr,
968         &dev_attr_name.attr,
969         NULL,
970 };
971 ATTRIBUTE_GROUPS(extcon);
972
973 static int create_extcon_class(void)
974 {
975         if (!extcon_class) {
976                 extcon_class = class_create(THIS_MODULE, "extcon");
977                 if (IS_ERR(extcon_class))
978                         return PTR_ERR(extcon_class);
979                 extcon_class->dev_groups = extcon_groups;
980
981 #if defined(CONFIG_ANDROID) && !defined(CONFIG_SWITCH)
982                 switch_class = class_compat_register("switch");
983                 if (WARN(!switch_class, "cannot allocate"))
984                         return -ENOMEM;
985 #endif /* CONFIG_ANDROID */
986         }
987
988         return 0;
989 }
990
991 static void extcon_dev_release(struct device *dev)
992 {
993 }
994
995 static const char *muex_name = "mutually_exclusive";
996 static void dummy_sysfs_dev_release(struct device *dev)
997 {
998 }
999
1000 /*
1001  * extcon_dev_allocate() - Allocate the memory of extcon device.
1002  * @supported_cable:    Array of supported extcon ending with EXTCON_NONE.
1003  *                      If supported_cable is NULL, cable name related APIs
1004  *                      are disabled.
1005  *
1006  * This function allocates the memory for extcon device without allocating
1007  * memory in each extcon provider driver and initialize default setting for
1008  * extcon device.
1009  *
1010  * Return the pointer of extcon device if success or ERR_PTR(err) if fail
1011  */
1012 struct extcon_dev *extcon_dev_allocate(const unsigned int *supported_cable)
1013 {
1014         struct extcon_dev *edev;
1015
1016         if (!supported_cable)
1017                 return ERR_PTR(-EINVAL);
1018
1019         edev = kzalloc(sizeof(*edev), GFP_KERNEL);
1020         if (!edev)
1021                 return ERR_PTR(-ENOMEM);
1022
1023         edev->max_supported = 0;
1024         edev->supported_cable = supported_cable;
1025
1026         return edev;
1027 }
1028
1029 /*
1030  * extcon_dev_free() - Free the memory of extcon device.
1031  * @edev:       the extcon device to free
1032  */
1033 void extcon_dev_free(struct extcon_dev *edev)
1034 {
1035         kfree(edev);
1036 }
1037 EXPORT_SYMBOL_GPL(extcon_dev_free);
1038
1039 /**
1040  * extcon_dev_register() - Register a new extcon device
1041  * @edev        : the new extcon device (should be allocated before calling)
1042  *
1043  * Among the members of edev struct, please set the "user initializing data"
1044  * in any case and set the "optional callbacks" if required. However, please
1045  * do not set the values of "internal data", which are initialized by
1046  * this function.
1047  */
1048 int extcon_dev_register(struct extcon_dev *edev)
1049 {
1050         int ret, index = 0;
1051         static atomic_t edev_no = ATOMIC_INIT(-1);
1052
1053         if (!extcon_class) {
1054                 ret = create_extcon_class();
1055                 if (ret < 0)
1056                         return ret;
1057         }
1058
1059         if (!edev || !edev->supported_cable)
1060                 return -EINVAL;
1061
1062         for (; edev->supported_cable[index] != EXTCON_NONE; index++);
1063
1064         edev->max_supported = index;
1065         if (index > SUPPORTED_CABLE_MAX) {
1066                 dev_err(&edev->dev,
1067                         "exceed the maximum number of supported cables\n");
1068                 return -EINVAL;
1069         }
1070
1071         edev->dev.class = extcon_class;
1072         edev->dev.release = extcon_dev_release;
1073
1074         edev->name = dev_name(edev->dev.parent);
1075         if (IS_ERR_OR_NULL(edev->name)) {
1076                 dev_err(&edev->dev,
1077                         "extcon device name is null\n");
1078                 return -EINVAL;
1079         }
1080         dev_set_name(&edev->dev, "extcon%lu",
1081                         (unsigned long)atomic_inc_return(&edev_no));
1082
1083         if (edev->max_supported) {
1084                 char buf[10];
1085                 char *str;
1086                 struct extcon_cable *cable;
1087
1088                 edev->cables = kzalloc(sizeof(struct extcon_cable) *
1089                                        edev->max_supported, GFP_KERNEL);
1090                 if (!edev->cables) {
1091                         ret = -ENOMEM;
1092                         goto err_sysfs_alloc;
1093                 }
1094                 for (index = 0; index < edev->max_supported; index++) {
1095                         cable = &edev->cables[index];
1096
1097                         snprintf(buf, 10, "cable.%d", index);
1098                         str = kzalloc(sizeof(char) * (strlen(buf) + 1),
1099                                       GFP_KERNEL);
1100                         if (!str) {
1101                                 for (index--; index >= 0; index--) {
1102                                         cable = &edev->cables[index];
1103                                         kfree(cable->attr_g.name);
1104                                 }
1105                                 ret = -ENOMEM;
1106
1107                                 goto err_alloc_cables;
1108                         }
1109                         strcpy(str, buf);
1110
1111                         cable->edev = edev;
1112                         cable->cable_index = index;
1113                         cable->attrs[0] = &cable->attr_name.attr;
1114                         cable->attrs[1] = &cable->attr_state.attr;
1115                         cable->attrs[2] = NULL;
1116                         cable->attr_g.name = str;
1117                         cable->attr_g.attrs = cable->attrs;
1118
1119                         sysfs_attr_init(&cable->attr_name.attr);
1120                         cable->attr_name.attr.name = "name";
1121                         cable->attr_name.attr.mode = 0444;
1122                         cable->attr_name.show = cable_name_show;
1123
1124                         sysfs_attr_init(&cable->attr_state.attr);
1125                         cable->attr_state.attr.name = "state";
1126                         cable->attr_state.attr.mode = 0444;
1127                         cable->attr_state.show = cable_state_show;
1128                 }
1129         }
1130
1131         if (edev->max_supported && edev->mutually_exclusive) {
1132                 char buf[80];
1133                 char *name;
1134
1135                 /* Count the size of mutually_exclusive array */
1136                 for (index = 0; edev->mutually_exclusive[index]; index++)
1137                         ;
1138
1139                 edev->attrs_muex = kzalloc(sizeof(struct attribute *) *
1140                                            (index + 1), GFP_KERNEL);
1141                 if (!edev->attrs_muex) {
1142                         ret = -ENOMEM;
1143                         goto err_muex;
1144                 }
1145
1146                 edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) *
1147                                              index, GFP_KERNEL);
1148                 if (!edev->d_attrs_muex) {
1149                         ret = -ENOMEM;
1150                         kfree(edev->attrs_muex);
1151                         goto err_muex;
1152                 }
1153
1154                 for (index = 0; edev->mutually_exclusive[index]; index++) {
1155                         sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
1156                         name = kzalloc(sizeof(char) * (strlen(buf) + 1),
1157                                        GFP_KERNEL);
1158                         if (!name) {
1159                                 for (index--; index >= 0; index--) {
1160                                         kfree(edev->d_attrs_muex[index].attr.
1161                                               name);
1162                                 }
1163                                 kfree(edev->d_attrs_muex);
1164                                 kfree(edev->attrs_muex);
1165                                 ret = -ENOMEM;
1166                                 goto err_muex;
1167                         }
1168                         strcpy(name, buf);
1169                         sysfs_attr_init(&edev->d_attrs_muex[index].attr);
1170                         edev->d_attrs_muex[index].attr.name = name;
1171                         edev->d_attrs_muex[index].attr.mode = 0000;
1172                         edev->attrs_muex[index] = &edev->d_attrs_muex[index]
1173                                                         .attr;
1174                 }
1175                 edev->attr_g_muex.name = muex_name;
1176                 edev->attr_g_muex.attrs = edev->attrs_muex;
1177
1178         }
1179
1180         if (edev->max_supported) {
1181                 edev->extcon_dev_type.groups =
1182                         kzalloc(sizeof(struct attribute_group *) *
1183                                 (edev->max_supported + 2), GFP_KERNEL);
1184                 if (!edev->extcon_dev_type.groups) {
1185                         ret = -ENOMEM;
1186                         goto err_alloc_groups;
1187                 }
1188
1189                 edev->extcon_dev_type.name = dev_name(&edev->dev);
1190                 edev->extcon_dev_type.release = dummy_sysfs_dev_release;
1191
1192                 for (index = 0; index < edev->max_supported; index++)
1193                         edev->extcon_dev_type.groups[index] =
1194                                 &edev->cables[index].attr_g;
1195                 if (edev->mutually_exclusive)
1196                         edev->extcon_dev_type.groups[index] =
1197                                 &edev->attr_g_muex;
1198
1199                 edev->dev.type = &edev->extcon_dev_type;
1200         }
1201
1202         ret = device_register(&edev->dev);
1203         if (ret) {
1204                 put_device(&edev->dev);
1205                 goto err_dev;
1206         }
1207 #if defined(CONFIG_ANDROID)
1208         if (switch_class)
1209                 ret = class_compat_create_link(switch_class, &edev->dev, NULL);
1210 #endif /* CONFIG_ANDROID */
1211
1212         spin_lock_init(&edev->lock);
1213
1214         edev->nh = devm_kzalloc(&edev->dev,
1215                         sizeof(*edev->nh) * edev->max_supported, GFP_KERNEL);
1216         if (!edev->nh) {
1217                 ret = -ENOMEM;
1218                 goto err_dev;
1219         }
1220
1221         for (index = 0; index < edev->max_supported; index++)
1222                 RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]);
1223
1224         dev_set_drvdata(&edev->dev, edev);
1225         edev->state = 0;
1226
1227         mutex_lock(&extcon_dev_list_lock);
1228         list_add(&edev->entry, &extcon_dev_list);
1229         mutex_unlock(&extcon_dev_list_lock);
1230
1231         return 0;
1232
1233 err_dev:
1234         if (edev->max_supported)
1235                 kfree(edev->extcon_dev_type.groups);
1236 err_alloc_groups:
1237         if (edev->max_supported && edev->mutually_exclusive) {
1238                 for (index = 0; edev->mutually_exclusive[index]; index++)
1239                         kfree(edev->d_attrs_muex[index].attr.name);
1240                 kfree(edev->d_attrs_muex);
1241                 kfree(edev->attrs_muex);
1242         }
1243 err_muex:
1244         for (index = 0; index < edev->max_supported; index++)
1245                 kfree(edev->cables[index].attr_g.name);
1246 err_alloc_cables:
1247         if (edev->max_supported)
1248                 kfree(edev->cables);
1249 err_sysfs_alloc:
1250         return ret;
1251 }
1252 EXPORT_SYMBOL_GPL(extcon_dev_register);
1253
1254 /**
1255  * extcon_dev_unregister() - Unregister the extcon device.
1256  * @edev:       the extcon device instance to be unregistered.
1257  *
1258  * Note that this does not call kfree(edev) because edev was not allocated
1259  * by this class.
1260  */
1261 void extcon_dev_unregister(struct extcon_dev *edev)
1262 {
1263         int index;
1264
1265         if (!edev)
1266                 return;
1267
1268         mutex_lock(&extcon_dev_list_lock);
1269         list_del(&edev->entry);
1270         mutex_unlock(&extcon_dev_list_lock);
1271
1272         if (IS_ERR_OR_NULL(get_device(&edev->dev))) {
1273                 dev_err(&edev->dev, "Failed to unregister extcon_dev (%s)\n",
1274                                 dev_name(&edev->dev));
1275                 return;
1276         }
1277
1278         device_unregister(&edev->dev);
1279
1280         if (edev->mutually_exclusive && edev->max_supported) {
1281                 for (index = 0; edev->mutually_exclusive[index];
1282                                 index++)
1283                         kfree(edev->d_attrs_muex[index].attr.name);
1284                 kfree(edev->d_attrs_muex);
1285                 kfree(edev->attrs_muex);
1286         }
1287
1288         for (index = 0; index < edev->max_supported; index++)
1289                 kfree(edev->cables[index].attr_g.name);
1290
1291         if (edev->max_supported) {
1292                 kfree(edev->extcon_dev_type.groups);
1293                 kfree(edev->cables);
1294         }
1295
1296 #if defined(CONFIG_ANDROID)
1297         if (switch_class)
1298                 class_compat_remove_link(switch_class, &edev->dev, NULL);
1299 #endif
1300         put_device(&edev->dev);
1301 }
1302 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
1303
1304 #ifdef CONFIG_OF
1305 /*
1306  * extcon_get_edev_by_phandle - Get the extcon device from devicetree
1307  * @dev - instance to the given device
1308  * @index - index into list of extcon_dev
1309  *
1310  * return the instance of extcon device
1311  */
1312 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
1313 {
1314         struct device_node *node;
1315         struct extcon_dev *edev;
1316
1317         if (!dev)
1318                 return ERR_PTR(-EINVAL);
1319
1320         if (!dev->of_node) {
1321                 dev_dbg(dev, "device does not have a device node entry\n");
1322                 return ERR_PTR(-EINVAL);
1323         }
1324
1325         node = of_parse_phandle(dev->of_node, "extcon", index);
1326         if (!node) {
1327                 dev_dbg(dev, "failed to get phandle in %s node\n",
1328                         dev->of_node->full_name);
1329                 return ERR_PTR(-ENODEV);
1330         }
1331
1332         mutex_lock(&extcon_dev_list_lock);
1333         list_for_each_entry(edev, &extcon_dev_list, entry) {
1334                 if (edev->dev.parent && edev->dev.parent->of_node == node) {
1335                         mutex_unlock(&extcon_dev_list_lock);
1336                         of_node_put(node);
1337                         return edev;
1338                 }
1339         }
1340         mutex_unlock(&extcon_dev_list_lock);
1341         of_node_put(node);
1342
1343         return ERR_PTR(-EPROBE_DEFER);
1344 }
1345 #else
1346 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
1347 {
1348         return ERR_PTR(-ENOSYS);
1349 }
1350 #endif /* CONFIG_OF */
1351 EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
1352
1353 /**
1354  * extcon_get_edev_name() - Get the name of the extcon device.
1355  * @edev:       the extcon device
1356  */
1357 const char *extcon_get_edev_name(struct extcon_dev *edev)
1358 {
1359         return !edev ? NULL : edev->name;
1360 }
1361
1362 static int __init extcon_class_init(void)
1363 {
1364         return create_extcon_class();
1365 }
1366 module_init(extcon_class_init);
1367
1368 static void __exit extcon_class_exit(void)
1369 {
1370 #if defined(CONFIG_ANDROID)
1371         class_compat_unregister(switch_class);
1372 #endif
1373         class_destroy(extcon_class);
1374 }
1375 module_exit(extcon_class_exit);
1376
1377 MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
1378 MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
1379 MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>");
1380 MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
1381 MODULE_DESCRIPTION("External connector (extcon) class driver");
1382 MODULE_LICENSE("GPL");