aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2012-11-26 22:06:49 -0500
committerChanwoo Choi <cw00.choi@samsung.com>2013-01-15 01:42:15 -0500
commitd0587eb794da221a5c210348abc8f6cceae93896 (patch)
tree91d1cd08e0a182625b68eeb5ba6f92b46ce15917
parent06bed0afa24e98b9afa26456c6bed37a6510f7d1 (diff)
extcon: max77693: Add support jig cable
This patch detect several kinds of JIG cable according to ADC value and set the hardware line path according to type of JIG cable(JIG-USB-ON /JIG-USB-OFF/JIG-UART-OFF). Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
-rw-r--r--drivers/extcon/extcon-max77693.c52
1 files changed, 46 insertions, 6 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 78dc7505b965..26ce4dfeda10 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -153,9 +153,10 @@ enum {
153 EXTCON_CABLE_CHARGE_DOWNSTREAM, 153 EXTCON_CABLE_CHARGE_DOWNSTREAM,
154 EXTCON_CABLE_MHL, 154 EXTCON_CABLE_MHL,
155 EXTCON_CABLE_MHL_TA, 155 EXTCON_CABLE_MHL_TA,
156 EXTCON_CABLE_JIG_USB_ON,
157 EXTCON_CABLE_JIG_USB_OFF,
158 EXTCON_CABLE_JIG_UART_OFF,
156 EXTCON_CABLE_AUDIO_VIDEO_LOAD, 159 EXTCON_CABLE_AUDIO_VIDEO_LOAD,
157 EXTCON_CABLE_AUDIO_VIDEO_NOLOAD,
158 EXTCON_CABLE_JIG,
159 160
160 _EXTCON_CABLE_NUM, 161 _EXTCON_CABLE_NUM,
161}; 162};
@@ -169,9 +170,11 @@ const char *max77693_extcon_cable[] = {
169 [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream", 170 [EXTCON_CABLE_CHARGE_DOWNSTREAM] = "Charge-downstream",
170 [EXTCON_CABLE_MHL] = "MHL", 171 [EXTCON_CABLE_MHL] = "MHL",
171 [EXTCON_CABLE_MHL_TA] = "MHL_TA", 172 [EXTCON_CABLE_MHL_TA] = "MHL_TA",
173 [EXTCON_CABLE_JIG_USB_ON] = "JIG-USB-ON",
174 [EXTCON_CABLE_JIG_USB_OFF] = "JIG-USB-OFF",
175 [EXTCON_CABLE_JIG_UART_OFF] = "JIG-UART-OFF",
172 [EXTCON_CABLE_AUDIO_VIDEO_LOAD] = "Audio-video-load", 176 [EXTCON_CABLE_AUDIO_VIDEO_LOAD] = "Audio-video-load",
173 [EXTCON_CABLE_AUDIO_VIDEO_NOLOAD] = "Audio-video-noload", 177
174 [EXTCON_CABLE_JIG] = "JIG",
175 NULL, 178 NULL,
176}; 179};
177 180
@@ -450,6 +453,44 @@ out:
450 return ret; 453 return ret;
451} 454}
452 455
456static int max77693_muic_jig_handler(struct max77693_muic_info *info,
457 int cable_type, bool attached)
458{
459 char cable_name[32];
460 int ret = 0;
461 u8 path = CONTROL1_SW_OPEN;
462
463 dev_info(info->dev,
464 "external connector is %s (adc:0x%02x)\n",
465 attached ? "attached" : "detached", cable_type);
466
467 switch (cable_type) {
468 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_OFF: /* ADC_JIG_USB_OFF */
469 /* PATH:AP_USB */
470 strcpy(cable_name, "JIG-USB-OFF");
471 path = CONTROL1_SW_USB;
472 break;
473 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: /* ADC_JIG_USB_ON */
474 /* PATH:AP_USB */
475 strcpy(cable_name, "JIG-USB-ON");
476 path = CONTROL1_SW_USB;
477 break;
478 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: /* ADC_JIG_UART_OFF */
479 /* PATH:AP_UART */
480 strcpy(cable_name, "JIG-UART-OFF");
481 path = CONTROL1_SW_UART;
482 break;
483 }
484
485 ret = max77693_muic_set_path(info, path, attached);
486 if (ret < 0)
487 goto out;
488
489 extcon_set_cable_state(info->edev, cable_name, attached);
490out:
491 return ret;
492}
493
453static int max77693_muic_adc_handler(struct max77693_muic_info *info) 494static int max77693_muic_adc_handler(struct max77693_muic_info *info)
454{ 495{
455 int cable_type; 496 int cable_type;
@@ -474,10 +515,9 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info)
474 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON: 515 case MAX77693_MUIC_ADC_FACTORY_MODE_USB_ON:
475 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF: 516 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF:
476 /* JIG */ 517 /* JIG */
477 ret = max77693_muic_set_path(info, CONTROL1_SW_UART, attached); 518 ret = max77693_muic_jig_handler(info, cable_type, attached);
478 if (ret < 0) 519 if (ret < 0)
479 goto out; 520 goto out;
480 extcon_set_cable_state(info->edev, "JIG", attached);
481 break; 521 break;
482 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: 522 case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON:
483 case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE: 523 case MAX77693_MUIC_ADC_AUDIO_MODE_REMOTE: