Lines Matching refs:info
154 * @info: the instance including private data of max14577 MUIC
157 static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
167 ret = max14577_update_reg(info->max14577->regmap,
172 dev_err(info->dev, "failed to set ADC debounce time\n");
177 dev_err(info->dev, "invalid ADC debounce time\n");
186 * @info: the instance including private data of max14577 MUIC
194 static int max14577_muic_set_path(struct max14577_muic_info *info,
201 ret = max14577_update_reg(info->max14577->regmap,
205 dev_err(info->dev, "failed to update MUIC register\n");
214 ret = max14577_update_reg(info->max14577->regmap,
218 dev_err(info->dev, "failed to update MUIC register\n");
227 ret = max14577_update_reg(info->max14577->regmap,
231 dev_err(info->dev, "failed to update MUIC register\n");
235 dev_dbg(info->dev,
244 * @info: the instance including private data of max14577 MUIC
253 static int max14577_muic_get_cable_type(struct max14577_muic_info *info,
266 adc = info->status[MAX14577_MUIC_STATUS1] & STATUS1_ADC_MASK;
271 * (info->prev_cable_type) for handling cable when cable is
277 cable_type = info->prev_cable_type;
278 info->prev_cable_type = MAX14577_MUIC_ADC_OPEN;
282 cable_type = info->prev_cable_type = adc;
290 chg_type = info->status[MAX14577_MUIC_STATUS2] &
297 cable_type = info->prev_chg_type;
298 info->prev_chg_type = MAX14577_CHARGER_TYPE_NONE;
304 * type(info->prev_chg_type) for handling cable when
307 cable_type = info->prev_chg_type = chg_type;
312 dev_err(info->dev, "Unknown cable group (%d)\n", group);
320 static int max14577_muic_jig_handler(struct max14577_muic_info *info,
326 dev_dbg(info->dev,
341 dev_err(info->dev, "failed to detect %s jig cable\n",
346 ret = max14577_muic_set_path(info, path, attached);
350 extcon_set_state_sync(info->edev, EXTCON_JIG, attached);
355 static int max14577_muic_adc_handler(struct max14577_muic_info *info)
362 cable_type = max14577_muic_get_cable_type(info,
365 dev_dbg(info->dev,
368 info->prev_cable_type);
375 ret = max14577_muic_jig_handler(info, cable_type, attached);
412 dev_info(info->dev,
417 dev_err(info->dev,
426 static int max14577_muic_chg_handler(struct max14577_muic_info *info)
432 chg_type = max14577_muic_get_cable_type(info,
435 dev_dbg(info->dev,
438 chg_type, info->prev_chg_type);
443 ret = max14577_muic_set_path(info, info->path_usb, attached);
447 extcon_set_state_sync(info->edev, EXTCON_USB, attached);
448 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
452 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
456 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
460 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
464 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
471 dev_err(info->dev,
482 struct max14577_muic_info *info = container_of(work,
486 if (!info->edev)
489 mutex_lock(&info->mutex);
491 ret = max14577_bulk_read(info->max14577->regmap,
492 MAX14577_MUIC_REG_STATUS1, info->status, 2);
494 dev_err(info->dev, "failed to read MUIC register\n");
495 mutex_unlock(&info->mutex);
499 if (info->irq_adc) {
500 ret = max14577_muic_adc_handler(info);
501 info->irq_adc = false;
503 if (info->irq_chg) {
504 ret = max14577_muic_chg_handler(info);
505 info->irq_chg = false;
509 dev_err(info->dev, "failed to handle MUIC interrupt\n");
511 mutex_unlock(&info->mutex);
518 static int max14577_parse_irq(struct max14577_muic_info *info, int irq_type)
528 info->irq_adc = true;
536 info->irq_chg = true;
547 static int max77836_parse_irq(struct max14577_muic_info *info, int irq_type)
550 if (max14577_parse_irq(info, irq_type))
555 info->irq_adc = true;
559 info->irq_chg = true;
568 struct max14577_muic_info *info = data;
578 for (i = 0; i < info->muic_irqs_num; i++)
579 if (irq == info->muic_irqs[i].virq)
580 irq_type = info->muic_irqs[i].irq;
582 switch (info->max14577->dev_type) {
584 irq_parsed = max77836_parse_irq(info, irq_type);
588 irq_parsed = max14577_parse_irq(info, irq_type);
593 dev_err(info->dev, "muic interrupt: irq %d occurred, skipped\n",
597 schedule_work(&info->irq_work);
602 static int max14577_muic_detect_accessory(struct max14577_muic_info *info)
609 mutex_lock(&info->mutex);
612 ret = max14577_bulk_read(info->max14577->regmap,
613 MAX14577_MUIC_REG_STATUS1, info->status, 2);
615 dev_err(info->dev, "failed to read MUIC register\n");
616 mutex_unlock(&info->mutex);
620 adc = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC,
623 ret = max14577_muic_adc_handler(info);
625 dev_err(info->dev, "Cannot detect accessory\n");
626 mutex_unlock(&info->mutex);
631 chg_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_CHG,
634 ret = max14577_muic_chg_handler(info);
636 dev_err(info->dev, "Cannot detect charger accessory\n");
637 mutex_unlock(&info->mutex);
642 mutex_unlock(&info->mutex);
649 struct max14577_muic_info *info = container_of(to_delayed_work(work),
652 max14577_muic_detect_accessory(info);
658 struct max14577_muic_info *info;
666 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
667 if (!info)
670 info->dev = &pdev->dev;
671 info->max14577 = max14577;
673 platform_set_drvdata(pdev, info);
674 mutex_init(&info->mutex);
676 INIT_WORK(&info->irq_work, max14577_muic_irq_work);
680 info->muic_irqs = max77836_muic_irqs;
681 info->muic_irqs_num = ARRAY_SIZE(max77836_muic_irqs);
685 info->muic_irqs = max14577_muic_irqs;
686 info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs);
690 for (i = 0; i < info->muic_irqs_num; i++) {
691 struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];
702 muic_irq->name, info);
712 info->edev = devm_extcon_dev_allocate(&pdev->dev,
714 if (IS_ERR(info->edev)) {
716 return PTR_ERR(info->edev);
719 ret = devm_extcon_dev_register(&pdev->dev, info->edev);
726 info->path_usb = CTRL1_SW_USB;
727 info->path_uart = CTRL1_SW_UART;
731 ret = max14577_bulk_read(info->max14577->regmap,
732 MAX14577_MUIC_REG_STATUS1, info->status, 2);
734 dev_err(info->dev, "Cannot read STATUS registers\n");
737 cable_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC,
740 max14577_muic_set_path(info, info->path_uart, true);
743 ret = max14577_read_reg(info->max14577->regmap,
749 dev_info(info->dev, "device ID : 0x%x\n", id);
752 max14577_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
762 INIT_DELAYED_WORK(&info->wq_detcable, max14577_muic_detect_cable_wq);
763 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
771 struct max14577_muic_info *info = platform_get_drvdata(pdev);
773 cancel_work_sync(&info->irq_work);