diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2014-05-28 01:21:55 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2014-07-22 21:22:35 -0400 |
commit | e1954452f500cb21c09ea401f6f431ab55b35ba3 (patch) | |
tree | b57000888eec8eaa33e4185af482eeac4eaa82a6 /drivers/extcon | |
parent | 914b881f9452fd615cc597b434fd8c0e12a7dae2 (diff) |
extcon: sm5502: Detect cable state after completing platform booting
This patch detect whether cable is connected or not and the cable type
after completing kernel/platform booting using system_power_efficient_wq.
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-sm5502.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c index 9f318c222b89..a32d40f97ff0 100644 --- a/drivers/extcon/extcon-sm5502.c +++ b/drivers/extcon/extcon-sm5502.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/extcon.h> | 28 | #include <linux/extcon.h> |
29 | #include <linux/extcon/sm5502.h> | 29 | #include <linux/extcon/sm5502.h> |
30 | 30 | ||
31 | #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */ | ||
32 | |||
31 | struct muic_irq { | 33 | struct muic_irq { |
32 | unsigned int irq; | 34 | unsigned int irq; |
33 | const char *name; | 35 | const char *name; |
@@ -59,6 +61,14 @@ struct sm5502_muic_info { | |||
59 | unsigned int num_reg_data; | 61 | unsigned int num_reg_data; |
60 | 62 | ||
61 | struct mutex mutex; | 63 | struct mutex mutex; |
64 | |||
65 | /* | ||
66 | * Use delayed workqueue to detect cable state and then | ||
67 | * notify cable state to notifiee/platform through uevent. | ||
68 | * After completing the booting of platform, the extcon provider | ||
69 | * driver should notify cable state to upper layer. | ||
70 | */ | ||
71 | struct delayed_work wq_detcable; | ||
62 | }; | 72 | }; |
63 | 73 | ||
64 | /* Default value of SM5502 register to bring up MUIC device. */ | 74 | /* Default value of SM5502 register to bring up MUIC device. */ |
@@ -341,6 +351,8 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info, | |||
341 | case SM5502_MUIC_ADC_OPEN_USB_OTG: | 351 | case SM5502_MUIC_ADC_OPEN_USB_OTG: |
342 | idx = EXTCON_CABLE_USB_HOST; | 352 | idx = EXTCON_CABLE_USB_HOST; |
343 | break; | 353 | break; |
354 | case SM5502_MUIC_ADC_GROUND: | ||
355 | break; | ||
344 | default: | 356 | default: |
345 | dev_dbg(info->dev, | 357 | dev_dbg(info->dev, |
346 | "cannot handle this cable_type (0x%x)\n", cable_type); | 358 | "cannot handle this cable_type (0x%x)\n", cable_type); |
@@ -433,6 +445,18 @@ static irqreturn_t sm5502_muic_irq_handler(int irq, void *data) | |||
433 | return IRQ_HANDLED; | 445 | return IRQ_HANDLED; |
434 | } | 446 | } |
435 | 447 | ||
448 | static void sm5502_muic_detect_cable_wq(struct work_struct *work) | ||
449 | { | ||
450 | struct sm5502_muic_info *info = container_of(to_delayed_work(work), | ||
451 | struct sm5502_muic_info, wq_detcable); | ||
452 | int ret; | ||
453 | |||
454 | /* Notify the state of connector cable or not */ | ||
455 | ret = sm5502_muic_cable_handler(info, true); | ||
456 | if (ret < 0) | ||
457 | dev_warn(info->dev, "failed to detect cable state\n"); | ||
458 | } | ||
459 | |||
436 | static void sm5502_init_dev_type(struct sm5502_muic_info *info) | 460 | static void sm5502_init_dev_type(struct sm5502_muic_info *info) |
437 | { | 461 | { |
438 | unsigned int reg_data, vendor_id, version_id; | 462 | unsigned int reg_data, vendor_id, version_id; |
@@ -546,6 +570,18 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2c, | |||
546 | return ret; | 570 | return ret; |
547 | } | 571 | } |
548 | 572 | ||
573 | /* | ||
574 | * Detect accessory after completing the initialization of platform | ||
575 | * | ||
576 | * - Use delayed workqueue to detect cable state and then | ||
577 | * notify cable state to notifiee/platform through uevent. | ||
578 | * After completing the booting of platform, the extcon provider | ||
579 | * driver should notify cable state to upper layer. | ||
580 | */ | ||
581 | INIT_DELAYED_WORK(&info->wq_detcable, sm5502_muic_detect_cable_wq); | ||
582 | queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, | ||
583 | msecs_to_jiffies(DELAY_MS_DEFAULT)); | ||
584 | |||
549 | /* Initialize SM5502 device and print vendor id and version id */ | 585 | /* Initialize SM5502 device and print vendor id and version id */ |
550 | sm5502_init_dev_type(info); | 586 | sm5502_init_dev_type(info); |
551 | 587 | ||