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