static void max8997_muic_detect_dev(struct max8997_muic_info *info) { struct i2c_client *client = info->muic; u8 status[2]; u8 adc, chgtyp, adcerr; int intr = INT_ATTACH; int ret; ret = max8997_bulk_read(client, MAX8997_MUIC_REG_STATUS1, 2, status); if (ret) { dev_err(info->dev, "%s: fail to read muic reg(%d)\n", __func__, ret); return; } dev_info(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__, status[0], status[1]); if (max8997_muic_handle_dock_vol_key(info, status[0])) return; adc = status[0] & STATUS1_ADC_MASK; adcerr = status[0] & STATUS1_ADCERR_MASK; chgtyp = status[1] & STATUS2_CHGTYP_MASK; if (!adcerr && adc == ADC_OPEN) { if (chgtyp == CHGTYP_NO_VOLTAGE) intr = INT_DETACH; else if (chgtyp == CHGTYP_USB || chgtyp == CHGTYP_DOWNSTREAM_PORT || chgtyp == CHGTYP_DEDICATED_CHGR || chgtyp == CHGTYP_500MA || chgtyp == CHGTYP_1A) { if (info->cable_type == CABLE_TYPE_OTG || info->cable_type == CABLE_TYPE_DESKDOCK || info->cable_type == CABLE_TYPE_CARDOCK) intr = INT_DETACH; } } if (intr == INT_ATTACH) { dev_info(info->dev, "%s: ATTACHED\n", __func__); max8997_muic_handle_attach(info, status[0], status[1]); } else { dev_info(info->dev, "%s: DETACHED\n", __func__); max8997_muic_handle_detach(info); } return; }
static void max8997_muic_detect_dev(struct max8997_muic_info *info, int irq) { struct i2c_client *client = info->muic; u8 status[2]; u8 adc, chgtyp, adcerr; int intr = INT_ATTACH; int ret; ret = max8997_bulk_read(client, MAX8997_MUIC_REG_STATUS1, 2, status); if (ret) { dev_err(info->dev, "%s: fail to read muic reg(%d)\n", __func__, ret); return; } dev_info(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__, status[0], status[1]); if ((irq == info->irq_adc) && max8997_muic_handle_dock_vol_key(info, status[0])) return; adc = status[0] & STATUS1_ADC_MASK; adcerr = status[0] & STATUS1_ADCERR_MASK; chgtyp = status[1] & STATUS2_CHGTYP_MASK; switch (adc) { case ADC_MHL: #if defined(CONFIG_MACH_U1) break; #endif case (ADC_MHL + 1): case (ADC_DOCK_VOL_DN - 1): case (ADC_DOCK_PLAY_PAUSE_KEY + 2) ... (ADC_CEA936ATYPE1_CHG - 1): case (ADC_CARDOCK + 1): dev_warn(info->dev, "%s: unsupported ADC(0x%02x)\n", __func__, adc); intr = INT_DETACH; break; case ADC_OPEN: if (!adcerr) { if (chgtyp == CHGTYP_NO_VOLTAGE) intr = INT_DETACH; else if (chgtyp == CHGTYP_USB || chgtyp == CHGTYP_DOWNSTREAM_PORT || chgtyp == CHGTYP_DEDICATED_CHGR || chgtyp == CHGTYP_500MA || chgtyp == CHGTYP_1A) { if (info->cable_type == CABLE_TYPE_OTG || info->cable_type == CABLE_TYPE_DESKDOCK || info->cable_type == CABLE_TYPE_CARDOCK) intr = INT_DETACH; } } break; default: break; } #if defined(CONFIG_MUIC_MAX8997_OVPUI) if (intr == INT_ATTACH) { if (irq == info->irq_chgins) { if (info->is_ovp_state) { max8997_muic_handle_attach(info, status[0], status[1]); info->is_ovp_state = false; dev_info(info->dev, "OVP recovered\n"); return; } else { dev_info(info->dev, "Just inserted TA/USB\n"); return; } } else if (irq == info->irq_chgrm) { max8997_muic_handle_detach(info); info->is_ovp_state = true; dev_info(info->dev, "OVP occured\n"); return; } } else { info->is_ovp_state = false; if (irq == info->irq_chgrm) { dev_info(info->dev, "Just removed TA/USB\n"); return; } } #endif if (intr == INT_ATTACH) { dev_info(info->dev, "%s: ATTACHED\n", __func__); max8997_muic_handle_attach(info, status[0], status[1]); } else { dev_info(info->dev, "%s: DETACHED\n", __func__); max8997_muic_handle_detach(info); } return; }