Lines Matching refs:info
204 static int max77843_muic_set_path(struct max77843_muic_info *info, in max77843_muic_set_path() argument
207 struct max77693_dev *max77843 = info->max77843; in max77843_muic_set_path()
226 dev_err(info->dev, "Cannot switch MUIC port\n"); in max77843_muic_set_path()
240 dev_err(info->dev, "Cannot update lowpower mode\n"); in max77843_muic_set_path()
244 dev_dbg(info->dev, in max77843_muic_set_path()
251 static void max77843_charger_set_otg_vbus(struct max77843_muic_info *info, in max77843_charger_set_otg_vbus() argument
254 struct max77693_dev *max77843 = info->max77843; in max77843_charger_set_otg_vbus()
266 static int max77843_muic_get_cable_type(struct max77843_muic_info *info, in max77843_muic_get_cable_type() argument
271 adc = info->status[MAX77843_MUIC_STATUS1] & in max77843_muic_get_cable_type()
279 cable_type = info->prev_cable_type; in max77843_muic_get_cable_type()
280 info->prev_cable_type = MAX77843_MUIC_ADC_OPEN; in max77843_muic_get_cable_type()
283 cable_type = info->prev_cable_type = adc; in max77843_muic_get_cable_type()
287 chg_type = info->status[MAX77843_MUIC_STATUS2] & in max77843_muic_get_cable_type()
299 cable_type = info->prev_chg_type; in max77843_muic_get_cable_type()
300 info->prev_chg_type = MAX77843_MUIC_CHG_NONE; in max77843_muic_get_cable_type()
309 info->prev_chg_type = MAX77843_MUIC_CHG_GND; in max77843_muic_get_cable_type()
317 cable_type = info->prev_chg_type; in max77843_muic_get_cable_type()
318 info->prev_chg_type = MAX77843_MUIC_CHG_NONE; in max77843_muic_get_cable_type()
322 info->prev_chg_type = MAX77843_MUIC_CHG_DOCK; in max77843_muic_get_cable_type()
329 cable_type = info->prev_chg_type; in max77843_muic_get_cable_type()
330 info->prev_chg_type = MAX77843_MUIC_CHG_NONE; in max77843_muic_get_cable_type()
333 cable_type = info->prev_chg_type = chg_type; in max77843_muic_get_cable_type()
339 cable_type = info->prev_gnd_type; in max77843_muic_get_cable_type()
340 info->prev_gnd_type = MAX77843_MUIC_ADC_OPEN; in max77843_muic_get_cable_type()
352 gnd_type = (info->status[MAX77843_MUIC_STATUS1] & in max77843_muic_get_cable_type()
356 gnd_type |= (info->status[MAX77843_MUIC_STATUS2] & in max77843_muic_get_cable_type()
362 cable_type = info->prev_gnd_type = gnd_type; in max77843_muic_get_cable_type()
366 dev_err(info->dev, "Unknown cable group (%d)\n", group); in max77843_muic_get_cable_type()
374 static int max77843_muic_adc_gnd_handler(struct max77843_muic_info *info) in max77843_muic_adc_gnd_handler() argument
379 gnd_cable_type = max77843_muic_get_cable_type(info, in max77843_muic_adc_gnd_handler()
381 dev_dbg(info->dev, "external connector is %s (gnd:0x%02x)\n", in max77843_muic_adc_gnd_handler()
387 ret = max77843_muic_set_path(info, in max77843_muic_adc_gnd_handler()
393 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); in max77843_muic_adc_gnd_handler()
394 max77843_charger_set_otg_vbus(info, attached); in max77843_muic_adc_gnd_handler()
398 ret = max77843_muic_set_path(info, in max77843_muic_adc_gnd_handler()
404 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); in max77843_muic_adc_gnd_handler()
407 dev_err(info->dev, "failed to detect %s accessory(gnd:0x%x)\n", in max77843_muic_adc_gnd_handler()
415 static int max77843_muic_jig_handler(struct max77843_muic_info *info, in max77843_muic_jig_handler() argument
421 dev_dbg(info->dev, "external connector is %s (adc:0x%02x)\n", in max77843_muic_jig_handler()
436 ret = max77843_muic_set_path(info, path, attached, false); in max77843_muic_jig_handler()
440 extcon_set_state_sync(info->edev, EXTCON_JIG, attached); in max77843_muic_jig_handler()
445 static int max77843_muic_dock_handler(struct max77843_muic_info *info, in max77843_muic_dock_handler() argument
450 dev_dbg(info->dev, "external connector is %s (adc: 0x10)\n", in max77843_muic_dock_handler()
453 ret = max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_USB, in max77843_muic_dock_handler()
458 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); in max77843_muic_dock_handler()
459 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); in max77843_muic_dock_handler()
460 extcon_set_state_sync(info->edev, EXTCON_DOCK, attached); in max77843_muic_dock_handler()
465 static int max77843_muic_adc_handler(struct max77843_muic_info *info) in max77843_muic_adc_handler() argument
470 cable_type = max77843_muic_get_cable_type(info, in max77843_muic_adc_handler()
473 dev_dbg(info->dev, in max77843_muic_adc_handler()
476 info->prev_cable_type); in max77843_muic_adc_handler()
480 ret = max77843_muic_dock_handler(info, attached); in max77843_muic_adc_handler()
485 ret = max77843_muic_adc_gnd_handler(info); in max77843_muic_adc_handler()
492 ret = max77843_muic_jig_handler(info, cable_type, attached); in max77843_muic_adc_handler()
523 dev_err(info->dev, in max77843_muic_adc_handler()
528 dev_err(info->dev, in max77843_muic_adc_handler()
537 static int max77843_muic_chg_handler(struct max77843_muic_info *info) in max77843_muic_chg_handler() argument
542 chg_type = max77843_muic_get_cable_type(info, in max77843_muic_chg_handler()
545 dev_dbg(info->dev, in max77843_muic_chg_handler()
548 chg_type, info->prev_chg_type); in max77843_muic_chg_handler()
552 ret = max77843_muic_set_path(info, in max77843_muic_chg_handler()
558 extcon_set_state_sync(info->edev, EXTCON_USB, attached); in max77843_muic_chg_handler()
559 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77843_muic_chg_handler()
563 ret = max77843_muic_set_path(info, in max77843_muic_chg_handler()
569 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP, in max77843_muic_chg_handler()
573 ret = max77843_muic_set_path(info, in max77843_muic_chg_handler()
579 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77843_muic_chg_handler()
583 ret = max77843_muic_set_path(info, in max77843_muic_chg_handler()
589 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW, in max77843_muic_chg_handler()
593 ret = max77843_muic_set_path(info, in max77843_muic_chg_handler()
599 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST, in max77843_muic_chg_handler()
603 gnd_type = max77843_muic_get_cable_type(info, in max77843_muic_chg_handler()
608 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77843_muic_chg_handler()
611 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77843_muic_chg_handler()
615 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, attached); in max77843_muic_chg_handler()
620 dev_err(info->dev, in max77843_muic_chg_handler()
624 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_OPEN, in max77843_muic_chg_handler()
634 struct max77843_muic_info *info = container_of(work, in max77843_muic_irq_work() local
636 struct max77693_dev *max77843 = info->max77843; in max77843_muic_irq_work()
639 mutex_lock(&info->mutex); in max77843_muic_irq_work()
642 MAX77843_MUIC_REG_STATUS1, info->status, in max77843_muic_irq_work()
645 dev_err(info->dev, "Cannot read STATUS registers\n"); in max77843_muic_irq_work()
646 mutex_unlock(&info->mutex); in max77843_muic_irq_work()
650 if (info->irq_adc) { in max77843_muic_irq_work()
651 ret = max77843_muic_adc_handler(info); in max77843_muic_irq_work()
653 dev_err(info->dev, "Unknown cable type\n"); in max77843_muic_irq_work()
654 info->irq_adc = false; in max77843_muic_irq_work()
657 if (info->irq_chg) { in max77843_muic_irq_work()
658 ret = max77843_muic_chg_handler(info); in max77843_muic_irq_work()
660 dev_err(info->dev, "Unknown charger type\n"); in max77843_muic_irq_work()
661 info->irq_chg = false; in max77843_muic_irq_work()
664 mutex_unlock(&info->mutex); in max77843_muic_irq_work()
669 struct max77843_muic_info *info = data; in max77843_muic_irq_handler() local
680 info->irq_adc = true; in max77843_muic_irq_handler()
687 info->irq_chg = true; in max77843_muic_irq_handler()
699 dev_err(info->dev, "Cannot recognize IRQ(%d)\n", irq_type); in max77843_muic_irq_handler()
703 schedule_work(&info->irq_work); in max77843_muic_irq_handler()
710 struct max77843_muic_info *info = container_of(to_delayed_work(work), in max77843_muic_detect_cable_wq() local
712 struct max77693_dev *max77843 = info->max77843; in max77843_muic_detect_cable_wq()
716 mutex_lock(&info->mutex); in max77843_muic_detect_cable_wq()
719 MAX77843_MUIC_REG_STATUS1, info->status, in max77843_muic_detect_cable_wq()
722 dev_err(info->dev, "Cannot read STATUS registers\n"); in max77843_muic_detect_cable_wq()
726 adc = max77843_muic_get_cable_type(info, in max77843_muic_detect_cable_wq()
729 ret = max77843_muic_adc_handler(info); in max77843_muic_detect_cable_wq()
731 dev_err(info->dev, "Cannot detect accessory\n"); in max77843_muic_detect_cable_wq()
736 chg_type = max77843_muic_get_cable_type(info, in max77843_muic_detect_cable_wq()
739 ret = max77843_muic_chg_handler(info); in max77843_muic_detect_cable_wq()
741 dev_err(info->dev, "Cannot detect charger accessory\n"); in max77843_muic_detect_cable_wq()
747 mutex_unlock(&info->mutex); in max77843_muic_detect_cable_wq()
750 static int max77843_muic_set_debounce_time(struct max77843_muic_info *info, in max77843_muic_set_debounce_time() argument
753 struct max77693_dev *max77843 = info->max77843; in max77843_muic_set_debounce_time()
766 dev_err(info->dev, "Cannot write MUIC regmap\n"); in max77843_muic_set_debounce_time()
771 dev_err(info->dev, "Invalid ADC debounce time\n"); in max77843_muic_set_debounce_time()
818 struct max77843_muic_info *info; in max77843_muic_probe() local
822 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in max77843_muic_probe()
823 if (!info) in max77843_muic_probe()
826 info->dev = &pdev->dev; in max77843_muic_probe()
827 info->max77843 = max77843; in max77843_muic_probe()
829 platform_set_drvdata(pdev, info); in max77843_muic_probe()
830 mutex_init(&info->mutex); in max77843_muic_probe()
847 info->edev = devm_extcon_dev_allocate(&pdev->dev, in max77843_muic_probe()
849 if (IS_ERR(info->edev)) { in max77843_muic_probe()
855 ret = devm_extcon_dev_register(&pdev->dev, info->edev); in max77843_muic_probe()
862 max77843_muic_set_debounce_time(info, MAX77843_DEBOUNCE_TIME_25MS); in max77843_muic_probe()
865 max77843_muic_set_path(info, MAX77843_MUIC_CONTROL1_SW_UART, true, in max77843_muic_probe()
874 dev_info(info->dev, "MUIC device ID : 0x%x\n", id); in max77843_muic_probe()
877 INIT_WORK(&info->irq_work, max77843_muic_irq_work); in max77843_muic_probe()
881 MAX77843_MUIC_REG_INT1, info->status, in max77843_muic_probe()
902 muic_irq->name, info); in max77843_muic_probe()
912 INIT_DELAYED_WORK(&info->wq_detcable, max77843_muic_detect_cable_wq); in max77843_muic_probe()
914 &info->wq_detcable, msecs_to_jiffies(DELAY_MS_DEFAULT)); in max77843_muic_probe()
927 struct max77843_muic_info *info = platform_get_drvdata(pdev); in max77843_muic_remove() local
928 struct max77693_dev *max77843 = info->max77843; in max77843_muic_remove()
930 cancel_work_sync(&info->irq_work); in max77843_muic_remove()