switch (time) { case ADC_DEBOUNCE_TIME_5MS: case ADC_DEBOUNCE_TIME_10MS: case ADC_DEBOUNCE_TIME_25MS: case ADC_DEBOUNCE_TIME_38_62MS:
ret = max14577_update_reg(info->max14577->regmap,
MAX14577_MUIC_REG_CONTROL3,
CTRL3_ADCDBSET_MASK,
time << CTRL3_ADCDBSET_SHIFT); if (ret) {
dev_err(info->dev, "failed to set ADC debounce time\n"); return ret;
} break; default:
dev_err(info->dev, "invalid ADC debounce time\n"); return -EINVAL;
}
/* Set open state to path before changing hw path */
ret = max14577_update_reg(info->max14577->regmap,
MAX14577_MUIC_REG_CONTROL1,
CLEAR_IDBEN_MICEN_MASK, CTRL1_SW_OPEN); if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n"); return ret;
}
if (attached)
ctrl1 = val; else
ctrl1 = CTRL1_SW_OPEN;
ret = max14577_update_reg(info->max14577->regmap,
MAX14577_MUIC_REG_CONTROL1,
CLEAR_IDBEN_MICEN_MASK, ctrl1); if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n"); return ret;
}
switch (cable_type) { case MAX14577_MUIC_ADC_FACTORY_MODE_USB_OFF: case MAX14577_MUIC_ADC_FACTORY_MODE_USB_ON: case MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF: /* JIG */
ret = max14577_muic_jig_handler(info, cable_type, attached); if (ret < 0) return ret; break; case MAX14577_MUIC_ADC_GROUND: case MAX14577_MUIC_ADC_SEND_END_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S1_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S2_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S3_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S4_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S5_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S6_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S7_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S8_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S9_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S10_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S11_BUTTON: case MAX14577_MUIC_ADC_REMOTE_S12_BUTTON: case MAX14577_MUIC_ADC_RESERVED_ACC_1: case MAX14577_MUIC_ADC_RESERVED_ACC_2: case MAX14577_MUIC_ADC_RESERVED_ACC_3: case MAX14577_MUIC_ADC_RESERVED_ACC_4: case MAX14577_MUIC_ADC_RESERVED_ACC_5: case MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE2: case MAX14577_MUIC_ADC_PHONE_POWERED_DEV: case MAX14577_MUIC_ADC_TTY_CONVERTER: case MAX14577_MUIC_ADC_UART_CABLE: case MAX14577_MUIC_ADC_CEA936A_TYPE1_CHG: case MAX14577_MUIC_ADC_AV_CABLE_NOLOAD: case MAX14577_MUIC_ADC_CEA936A_TYPE2_CHG: case MAX14577_MUIC_ADC_FACTORY_MODE_UART_ON: case MAX14577_MUIC_ADC_AUDIO_DEVICE_TYPE1: /* *Thisaccessoryisn'tusedingeneralcaseifitisspecially *neededtodetectadditionalaccessory,shouldimplement *properoperationwhenthisaccessoryisattached/detached.
*/
dev_info(info->dev, "accessory is %s but it isn't used (adc:0x%x)\n",
attached ? "attached" : "detached", cable_type); return -EAGAIN; default:
dev_err(info->dev, "failed to detect %s accessory (adc:0x%x)\n",
attached ? "attached" : "detached", cable_type); return -EINVAL;
}
return0;
}
staticint max14577_muic_chg_handler(struct max14577_muic_info *info)
{ int chg_type; bool attached; int ret = 0;
switch (chg_type) { case MAX14577_CHARGER_TYPE_USB: /* PATH:AP_USB */
ret = max14577_muic_set_path(info, info->path_usb, attached); if (ret < 0) return ret;
extcon_set_state_sync(info->edev, EXTCON_USB, attached);
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
attached); break; case MAX14577_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
attached); break; case MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT:
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
attached); break; case MAX14577_CHARGER_TYPE_SPECIAL_500MA:
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
attached); break; case MAX14577_CHARGER_TYPE_SPECIAL_1A:
extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
attached); break; case MAX14577_CHARGER_TYPE_NONE: case MAX14577_CHARGER_TYPE_DEAD_BATTERY: break; default:
dev_err(info->dev, "failed to detect %s accessory (chg_type:0x%x)\n",
attached ? "attached" : "detached", chg_type); return -EINVAL;
}
return0;
}
staticvoid max14577_muic_irq_work(struct work_struct *work)
{ struct max14577_muic_info *info = container_of(work, struct max14577_muic_info, irq_work); int ret = 0;
if (!info->edev) return;
mutex_lock(&info->mutex);
ret = max14577_bulk_read(info->max14577->regmap,
MAX14577_MUIC_REG_STATUS1, info->status, 2); if (ret) {
dev_err(info->dev, "failed to read MUIC register\n");
mutex_unlock(&info->mutex); return;
}
if (info->irq_adc) {
ret = max14577_muic_adc_handler(info);
info->irq_adc = false;
} if (info->irq_chg) {
ret = max14577_muic_chg_handler(info);
info->irq_chg = false;
}
if (ret < 0)
dev_err(info->dev, "failed to handle MUIC interrupt\n");
mutex_unlock(&info->mutex);
}
/* *Setsirq_adcorirq_chginmax14577_muic_infoandreturns1. *Returns0ifirq_typedoesnotmatchregisteredIRQforthisdevicetype.
*/ staticint max14577_parse_irq(struct max14577_muic_info *info, int irq_type)
{ switch (irq_type) { case MAX14577_IRQ_INT1_ADC: case MAX14577_IRQ_INT1_ADCLOW: case MAX14577_IRQ_INT1_ADCERR: /* *Handleallofaccessoryexceptfor *typeofchargeraccessory.
*/
info->irq_adc = true; return1; case MAX14577_IRQ_INT2_CHGTYP: case MAX14577_IRQ_INT2_CHGDETRUN: case MAX14577_IRQ_INT2_DCDTMR: case MAX14577_IRQ_INT2_DBCHG: case MAX14577_IRQ_INT2_VBVOLT: /* Handle charger accessory */
info->irq_chg = true; return1; default: return0;
}
}
/* *Setsirq_adcorirq_chginmax14577_muic_infoandreturns1. *Returns0ifirq_typedoesnotmatchregisteredIRQforthisdevicetype.
*/ staticint max77836_parse_irq(struct max14577_muic_info *info, int irq_type)
{ /* First check common max14577 interrupts */ if (max14577_parse_irq(info, irq_type)) return1;
/* Support irq domain for max14577 MUIC device */ for (i = 0; i < info->muic_irqs_num; i++) { struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; int virq = 0;
/* Set initial path for UART when JIG is connected to get serial logs */
ret = max14577_bulk_read(info->max14577->regmap,
MAX14577_MUIC_REG_STATUS1, info->status, 2); if (ret) {
dev_err(info->dev, "Cannot read STATUS registers\n"); return ret;
}
cable_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC,
&attached); if (attached && cable_type == MAX14577_MUIC_ADC_FACTORY_MODE_UART_OFF)
max14577_muic_set_path(info, info->path_uart, true);
/* Check revision number of MUIC device*/
ret = max14577_read_reg(info->max14577->regmap,
MAX14577_REG_DEVICEID, &id); if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n"); return ret;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
/* Set ADC debounce time */
max14577_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.