mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
extcon: sm5502: Detect OTG when USB_ID is connected to ground
In it's curent state this driver ignores OTG adapters with ID pin connected to ground. This commit adds a check to set extcon into host mode when such OTG adapter is connected. Signed-off-by: Nikita Travkin <nikitos.tr@gmail.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
This commit is contained in:
parent
17e8ff013e
commit
e3f6032909
1 changed files with 20 additions and 2 deletions
|
@ -144,6 +144,7 @@ enum sm5502_muic_acc_type {
|
|||
SM5502_MUIC_ADC_AUDIO_TYPE1_FULL_REMOTE = 0x3e, /* | 001|11110| */
|
||||
SM5502_MUIC_ADC_AUDIO_TYPE1_SEND_END = 0x5e, /* | 010|11110| */
|
||||
/* |Dev Type1|--ADC| */
|
||||
SM5502_MUIC_ADC_GROUND_USB_OTG = 0x80, /* | 100|00000| */
|
||||
SM5502_MUIC_ADC_OPEN_USB = 0x5f, /* | 010|11111| */
|
||||
SM5502_MUIC_ADC_OPEN_TA = 0xdf, /* | 110|11111| */
|
||||
SM5502_MUIC_ADC_OPEN_USB_OTG = 0xff, /* | 111|11111| */
|
||||
|
@ -291,11 +292,27 @@ static unsigned int sm5502_muic_get_cable_type(struct sm5502_muic_info *info)
|
|||
* connected with to MUIC device.
|
||||
*/
|
||||
cable_type = adc & SM5502_REG_ADC_MASK;
|
||||
if (cable_type == SM5502_MUIC_ADC_GROUND)
|
||||
return SM5502_MUIC_ADC_GROUND;
|
||||
|
||||
switch (cable_type) {
|
||||
case SM5502_MUIC_ADC_GROUND:
|
||||
ret = regmap_read(info->regmap, SM5502_REG_DEV_TYPE1,
|
||||
&dev_type1);
|
||||
if (ret) {
|
||||
dev_err(info->dev, "failed to read DEV_TYPE1 reg\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (dev_type1) {
|
||||
case SM5502_REG_DEV_TYPE1_USB_OTG_MASK:
|
||||
cable_type = SM5502_MUIC_ADC_GROUND_USB_OTG;
|
||||
break;
|
||||
default:
|
||||
dev_dbg(info->dev,
|
||||
"cannot identify the cable type: adc(0x%x), dev_type1(0x%x)\n",
|
||||
adc, dev_type1);
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case SM5502_MUIC_ADC_SEND_END_BUTTON:
|
||||
case SM5502_MUIC_ADC_REMOTE_S1_BUTTON:
|
||||
case SM5502_MUIC_ADC_REMOTE_S2_BUTTON:
|
||||
|
@ -396,6 +413,7 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info,
|
|||
con_sw = DM_DP_SWITCH_OPEN;
|
||||
vbus_sw = VBUSIN_SWITCH_VBUSOUT;
|
||||
break;
|
||||
case SM5502_MUIC_ADC_GROUND_USB_OTG:
|
||||
case SM5502_MUIC_ADC_OPEN_USB_OTG:
|
||||
id = EXTCON_USB_HOST;
|
||||
con_sw = DM_DP_SWITCH_USB;
|
||||
|
|
Loading…
Reference in a new issue