Lines Matching refs:info
155 * @info: the instance including private data of max14577 MUIC
158 static int max14577_muic_set_debounce_time(struct max14577_muic_info *info,
168 ret = max14577_update_reg(info->max14577->regmap,
173 dev_err(info->dev, "failed to set ADC debounce time\n");
178 dev_err(info->dev, "invalid ADC debounce time\n");
187 * @info: the instance including private data of max14577 MUIC
195 static int max14577_muic_set_path(struct max14577_muic_info *info,
202 ret = max14577_update_reg(info->max14577->regmap,
206 dev_err(info->dev, "failed to update MUIC register\n");
215 ret = max14577_update_reg(info->max14577->regmap,
219 dev_err(info->dev, "failed to update MUIC register\n");
228 ret = max14577_update_reg(info->max14577->regmap,
232 dev_err(info->dev, "failed to update MUIC register\n");
236 dev_dbg(info->dev,
245 * @info: the instance including private data of max14577 MUIC
254 static int max14577_muic_get_cable_type(struct max14577_muic_info *info,
267 adc = info->status[MAX14577_MUIC_STATUS1] & STATUS1_ADC_MASK;
272 * (info->prev_cable_type) for handling cable when cable is
278 cable_type = info->prev_cable_type;
279 info->prev_cable_type = MAX14577_MUIC_ADC_OPEN;
283 cable_type = info->prev_cable_type = adc;
291 chg_type = info->status[MAX14577_MUIC_STATUS2] &
298 cable_type = info->prev_chg_type;
299 info->prev_chg_type = MAX14577_CHARGER_TYPE_NONE;
305 * type(info->prev_chg_type) for handling cable when
308 cable_type = info->prev_chg_type = chg_type;
313 dev_err(info->dev, "Unknown cable group (%d)\n", group);
321 static int max14577_muic_jig_handler(struct max14577_muic_info *info,
327 dev_dbg(info->dev,
342 dev_err(info->dev, "failed to detect %s jig cable\n",
347 ret = max14577_muic_set_path(info, path, attached);
351 extcon_set_state_sync(info->edev, EXTCON_JIG, attached);
356 static int max14577_muic_adc_handler(struct max14577_muic_info *info)
363 cable_type = max14577_muic_get_cable_type(info,
366 dev_dbg(info->dev,
369 info->prev_cable_type);
376 ret = max14577_muic_jig_handler(info, cable_type, attached);
413 dev_info(info->dev,
418 dev_err(info->dev,
427 static int max14577_muic_chg_handler(struct max14577_muic_info *info)
433 chg_type = max14577_muic_get_cable_type(info,
436 dev_dbg(info->dev,
439 chg_type, info->prev_chg_type);
444 ret = max14577_muic_set_path(info, info->path_usb, attached);
448 extcon_set_state_sync(info->edev, EXTCON_USB, attached);
449 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
453 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
457 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
461 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
465 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
472 dev_err(info->dev,
483 struct max14577_muic_info *info = container_of(work,
487 if (!info->edev)
490 mutex_lock(&info->mutex);
492 ret = max14577_bulk_read(info->max14577->regmap,
493 MAX14577_MUIC_REG_STATUS1, info->status, 2);
495 dev_err(info->dev, "failed to read MUIC register\n");
496 mutex_unlock(&info->mutex);
500 if (info->irq_adc) {
501 ret = max14577_muic_adc_handler(info);
502 info->irq_adc = false;
504 if (info->irq_chg) {
505 ret = max14577_muic_chg_handler(info);
506 info->irq_chg = false;
510 dev_err(info->dev, "failed to handle MUIC interrupt\n");
512 mutex_unlock(&info->mutex);
519 static int max14577_parse_irq(struct max14577_muic_info *info, int irq_type)
529 info->irq_adc = true;
537 info->irq_chg = true;
548 static int max77836_parse_irq(struct max14577_muic_info *info, int irq_type)
551 if (max14577_parse_irq(info, irq_type))
556 info->irq_adc = true;
560 info->irq_chg = true;
569 struct max14577_muic_info *info = data;
579 for (i = 0; i < info->muic_irqs_num; i++)
580 if (irq == info->muic_irqs[i].virq)
581 irq_type = info->muic_irqs[i].irq;
583 switch (info->max14577->dev_type) {
585 irq_parsed = max77836_parse_irq(info, irq_type);
589 irq_parsed = max14577_parse_irq(info, irq_type);
594 dev_err(info->dev, "muic interrupt: irq %d occurred, skipped\n",
598 schedule_work(&info->irq_work);
603 static int max14577_muic_detect_accessory(struct max14577_muic_info *info)
610 mutex_lock(&info->mutex);
613 ret = max14577_bulk_read(info->max14577->regmap,
614 MAX14577_MUIC_REG_STATUS1, info->status, 2);
616 dev_err(info->dev, "failed to read MUIC register\n");
617 mutex_unlock(&info->mutex);
621 adc = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC,
624 ret = max14577_muic_adc_handler(info);
626 dev_err(info->dev, "Cannot detect accessory\n");
627 mutex_unlock(&info->mutex);
632 chg_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_CHG,
635 ret = max14577_muic_chg_handler(info);
637 dev_err(info->dev, "Cannot detect charger accessory\n");
638 mutex_unlock(&info->mutex);
643 mutex_unlock(&info->mutex);
650 struct max14577_muic_info *info = container_of(to_delayed_work(work),
653 max14577_muic_detect_accessory(info);
659 struct max14577_muic_info *info;
667 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
668 if (!info)
671 info->dev = &pdev->dev;
672 info->max14577 = max14577;
674 platform_set_drvdata(pdev, info);
675 mutex_init(&info->mutex);
677 ret = devm_work_autocancel(&pdev->dev, &info->irq_work,
684 info->muic_irqs = max77836_muic_irqs;
685 info->muic_irqs_num = ARRAY_SIZE(max77836_muic_irqs);
689 info->muic_irqs = max14577_muic_irqs;
690 info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs);
694 for (i = 0; i < info->muic_irqs_num; i++) {
695 struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];
706 muic_irq->name, info);
716 info->edev = devm_extcon_dev_allocate(&pdev->dev,
718 if (IS_ERR(info->edev)) {
720 return PTR_ERR(info->edev);
723 ret = devm_extcon_dev_register(&pdev->dev, info->edev);
730 info->path_usb = CTRL1_SW_USB;
731 info->path_uart = CTRL1_SW_UART;
735 ret = max14577_bulk_read(info->max14577->regmap,
736 MAX14577_MUIC_REG_STATUS1, info->status, 2);
738 dev_err(info->dev, "Cannot read STATUS registers\n");
741 cable_type = max14577_muic_get_cable_type(info, MAX14577_CABLE_GROUP_ADC,
744 max14577_muic_set_path(info, info->path_uart, true);
747 ret = max14577_read_reg(info->max14577->regmap,
753 dev_info(info->dev, "device ID : 0x%x\n", id);
756 max14577_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
766 INIT_DELAYED_WORK(&info->wq_detcable, max14577_muic_detect_cable_wq);
767 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,