diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2012-11-26 21:30:35 -0500 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-01-15 01:42:15 -0500 |
commit | 06bed0afa24e98b9afa26456c6bed37a6510f7d1 (patch) | |
tree | d4d4bc2f8da8a15171c34fe516849f9ab808b158 /drivers/extcon | |
parent | 154f757fd315270e42bd17f4a68d84bd070e5758 (diff) |
extcon: max77693: Add support MHL_TA cable for charging battery
This patch support MHL_TA cable for charging battery. The MHL_TA
cable include MHL with TA cable or MHL with micro USB cable. When
MHL with TA/USB cable is attached, extcon-max77693 driver detect
two interrupt for handling precise operation according to each cable
(MHL and TA/USB cable).
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-max77693.c | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index e84d5dc06798..78dc7505b965 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c | |||
@@ -136,9 +136,11 @@ enum max77693_muic_acc_type { | |||
136 | 136 | ||
137 | /* The below accessories have same ADC value so ADCLow and | 137 | /* The below accessories have same ADC value so ADCLow and |
138 | ADC1K bit is used to separate specific accessory */ | 138 | ADC1K bit is used to separate specific accessory */ |
139 | MAX77693_MUIC_GND_USB_OTG = 0x100, /* ADC:0x0, ADCLow:0, ADC1K:0 */ | 139 | MAX77693_MUIC_GND_USB_OTG = 0x100, /* ADC:0x0, VBVolot:0, ADCLow:0, ADC1K:0 */ |
140 | MAX77693_MUIC_GND_AV_CABLE_LOAD = 0x102,/* ADC:0x0, ADCLow:1, ADC1K:0 */ | 140 | MAX77693_MUIC_GND_USB_OTG_VB = 0x104, /* ADC:0x0, VBVolot:1, ADCLow:0, ADC1K:0 */ |
141 | MAX77693_MUIC_GND_MHL_CABLE = 0x103, /* ADC:0x0, ADCLow:1, ADC1K:1 */ | 141 | MAX77693_MUIC_GND_AV_CABLE_LOAD = 0x102,/* ADC:0x0, VBVolot:0, ADCLow:1, ADC1K:0 */ |
142 | MAX77693_MUIC_GND_MHL = 0x103, /* ADC:0x0, VBVolot:0, ADCLow:1, ADC1K:1 */ | ||
143 | MAX77693_MUIC_GND_MHL_VB = 0x107, /* ADC:0x0, VBVolot:1, ADCLow:1, ADC1K:1 */ | ||
142 | }; | 144 | }; |
143 | 145 | ||
144 | /* MAX77693 MUIC device support below list of accessories(external connector) */ | 146 | /* MAX77693 MUIC device support below list of accessories(external connector) */ |
@@ -150,6 +152,7 @@ enum { | |||
150 | EXTCON_CABLE_SLOW_CHARGER, | 152 | EXTCON_CABLE_SLOW_CHARGER, |
151 | EXTCON_CABLE_CHARGE_DOWNSTREAM, | 153 | EXTCON_CABLE_CHARGE_DOWNSTREAM, |
152 | EXTCON_CABLE_MHL, | 154 | EXTCON_CABLE_MHL, |
155 | EXTCON_CABLE_MHL_TA, | ||
153 | EXTCON_CABLE_AUDIO_VIDEO_LOAD, | 156 | EXTCON_CABLE_AUDIO_VIDEO_LOAD, |
154 | EXTCON_CABLE_AUDIO_VIDEO_NOLOAD, | 157 | EXTCON_CABLE_AUDIO_VIDEO_NOLOAD, |
155 | EXTCON_CABLE_JIG, | 158 | EXTCON_CABLE_JIG, |
@@ -165,6 +168,7 @@ const char *max77693_extcon_cable[] = { | |||
165 | [EXTCON_CABLE_SLOW_CHARGER] = "Slow-charger", | 168 | [EXTCON_CABLE_SLOW_CHARGER] = "Slow-charger", |
166 | [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", | 169 | [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", |
167 | [EXTCON_CABLE_MHL] = "MHL", | 170 | [EXTCON_CABLE_MHL] = "MHL", |
171 | [EXTCON_CABLE_MHL_TA] = "MHL_TA", | ||
168 | [EXTCON_CABLE_AUDIO_VIDEO_LOAD] = "Audio-video-load", | 172 | [EXTCON_CABLE_AUDIO_VIDEO_LOAD] = "Audio-video-load", |
169 | [EXTCON_CABLE_AUDIO_VIDEO_NOLOAD] = "Audio-video-noload", | 173 | [EXTCON_CABLE_AUDIO_VIDEO_NOLOAD] = "Audio-video-noload", |
170 | [EXTCON_CABLE_JIG] = "JIG", | 174 | [EXTCON_CABLE_JIG] = "JIG", |
@@ -330,6 +334,7 @@ static int max77693_muic_get_cable_type(struct max77693_muic_info *info, | |||
330 | /** | 334 | /** |
331 | * [0x1][VBVolt][ADCLow][ADC1K] | 335 | * [0x1][VBVolt][ADCLow][ADC1K] |
332 | * [0x1 0 0 0 ] : USB_OTG | 336 | * [0x1 0 0 0 ] : USB_OTG |
337 | * [0x1 1 0 0 ] : USB_OTG_VB | ||
333 | * [0x1 0 1 0 ] : Audio Video Cable with load | 338 | * [0x1 0 1 0 ] : Audio Video Cable with load |
334 | * [0x1 0 1 1 ] : MHL without charging connector | 339 | * [0x1 0 1 1 ] : MHL without charging connector |
335 | * [0x1 1 1 1 ] : MHL with charging connector | 340 | * [0x1 1 1 1 ] : MHL with charging connector |
@@ -414,22 +419,24 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) | |||
414 | 419 | ||
415 | switch (cable_type_gnd) { | 420 | switch (cable_type_gnd) { |
416 | case MAX77693_MUIC_GND_USB_OTG: | 421 | case MAX77693_MUIC_GND_USB_OTG: |
417 | /* USB_OTG */ | 422 | case MAX77693_MUIC_GND_USB_OTG_VB: |
423 | /* USB_OTG, PATH: AP_USB */ | ||
418 | ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); | 424 | ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); |
419 | if (ret < 0) | 425 | if (ret < 0) |
420 | goto out; | 426 | goto out; |
421 | extcon_set_cable_state(info->edev, "USB-Host", attached); | 427 | extcon_set_cable_state(info->edev, "USB-Host", attached); |
422 | break; | 428 | break; |
423 | case MAX77693_MUIC_GND_AV_CABLE_LOAD: | 429 | case MAX77693_MUIC_GND_AV_CABLE_LOAD: |
424 | /* Audio Video Cable with load */ | 430 | /* Audio Video Cable with load, PATH:AUDIO */ |
425 | ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); | 431 | ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); |
426 | if (ret < 0) | 432 | if (ret < 0) |
427 | goto out; | 433 | goto out; |
428 | extcon_set_cable_state(info->edev, | 434 | extcon_set_cable_state(info->edev, |
429 | "Audio-video-load", attached); | 435 | "Audio-video-load", attached); |
430 | break; | 436 | break; |
431 | case MAX77693_MUIC_GND_MHL_CABLE: | 437 | case MAX77693_MUIC_GND_MHL: |
432 | /* MHL */ | 438 | case MAX77693_MUIC_GND_MHL_VB: |
439 | /* MHL or MHL with USB/TA cable */ | ||
433 | extcon_set_cable_state(info->edev, "MHL", attached); | 440 | extcon_set_cable_state(info->edev, "MHL", attached); |
434 | break; | 441 | break; |
435 | default: | 442 | default: |
@@ -528,7 +535,9 @@ out: | |||
528 | static int max77693_muic_chg_handler(struct max77693_muic_info *info) | 535 | static int max77693_muic_chg_handler(struct max77693_muic_info *info) |
529 | { | 536 | { |
530 | int chg_type; | 537 | int chg_type; |
538 | int cable_type_gnd; | ||
531 | bool attached; | 539 | bool attached; |
540 | bool cable_attached; | ||
532 | int ret = 0; | 541 | int ret = 0; |
533 | 542 | ||
534 | chg_type = max77693_muic_get_cable_type(info, | 543 | chg_type = max77693_muic_get_cable_type(info, |
@@ -541,10 +550,35 @@ static int max77693_muic_chg_handler(struct max77693_muic_info *info) | |||
541 | 550 | ||
542 | switch (chg_type) { | 551 | switch (chg_type) { |
543 | case MAX77693_CHARGER_TYPE_USB: | 552 | case MAX77693_CHARGER_TYPE_USB: |
544 | ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); | 553 | cable_type_gnd = max77693_muic_get_cable_type(info, |
545 | if (ret < 0) | 554 | MAX77693_CABLE_GROUP_ADC_GND, |
546 | goto out; | 555 | &cable_attached); |
547 | extcon_set_cable_state(info->edev, "USB", attached); | 556 | |
557 | switch (cable_type_gnd) { | ||
558 | case MAX77693_MUIC_GND_MHL: | ||
559 | case MAX77693_MUIC_GND_MHL_VB: | ||
560 | /* | ||
561 | * USB/TA with MHL cable | ||
562 | * - MHL cable, which connect micro USB or TA cable, | ||
563 | * is used to charging battery. So, extcon driver check | ||
564 | * charging type whether micro USB or TA cable is | ||
565 | * connected to MHL cable when extcon driver detect MHL | ||
566 | * cable. | ||
567 | */ | ||
568 | extcon_set_cable_state(info->edev, "MHL_TA", attached); | ||
569 | |||
570 | if (!cable_attached) | ||
571 | extcon_set_cable_state(info->edev, | ||
572 | "MHL", false); | ||
573 | break; | ||
574 | default: | ||
575 | /* Only USB cable, PATH:AP_USB */ | ||
576 | ret = max77693_muic_set_path(info, CONTROL1_SW_USB, | ||
577 | attached); | ||
578 | if (ret < 0) | ||
579 | goto out; | ||
580 | extcon_set_cable_state(info->edev, "USB", attached); | ||
581 | } | ||
548 | break; | 582 | break; |
549 | case MAX77693_CHARGER_TYPE_DOWNSTREAM_PORT: | 583 | case MAX77693_CHARGER_TYPE_DOWNSTREAM_PORT: |
550 | extcon_set_cable_state(info->edev, | 584 | extcon_set_cable_state(info->edev, |