Lines Matching refs:info
154 * @info: the instance including private data of max8997 MUIC
157 static int max8997_muic_set_debounce_time(struct max8997_muic_info *info,
167 ret = max8997_update_reg(info->muic,
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 max8997 MUIC
194 static int max8997_muic_set_path(struct max8997_muic_info *info,
205 ret = max8997_update_reg(info->muic,
208 dev_err(info->dev, "failed to update MUIC register\n");
217 ret = max8997_update_reg(info->muic,
221 dev_err(info->dev, "failed to update MUIC register\n");
225 dev_info(info->dev,
234 * @info: the instance including private data of max8997 MUIC
243 static int max8997_muic_get_cable_type(struct max8997_muic_info *info,
256 adc = info->status[0] & STATUS1_ADC_MASK;
261 * (info->prev_cable_type) for handling cable when cable is
267 cable_type = info->prev_cable_type;
268 info->prev_cable_type = MAX8997_MUIC_ADC_OPEN;
272 cable_type = info->prev_cable_type = adc;
280 chg_type = info->status[1] & STATUS2_CHGTYP_MASK;
286 cable_type = info->prev_chg_type;
287 info->prev_chg_type = MAX8997_CHARGER_TYPE_NONE;
293 * type(info->prev_chg_type) for handling cable when
296 cable_type = info->prev_chg_type = chg_type;
301 dev_err(info->dev, "Unknown cable group (%d)\n", group);
309 static int max8997_muic_handle_usb(struct max8997_muic_info *info,
314 ret = max8997_muic_set_path(info, info->path_usb, attached);
316 dev_err(info->dev, "failed to update muic register\n");
322 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
325 extcon_set_state_sync(info->edev, EXTCON_USB, attached);
326 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
330 dev_err(info->dev, "failed to detect %s usb cable\n",
338 static int max8997_muic_handle_dock(struct max8997_muic_info *info,
343 ret = max8997_muic_set_path(info, CONTROL1_SW_AUDIO, attached);
345 dev_err(info->dev, "failed to update muic register\n");
352 extcon_set_state_sync(info->edev, EXTCON_DOCK, attached);
355 dev_err(info->dev, "failed to detect %s dock device\n",
363 static int max8997_muic_handle_jig_uart(struct max8997_muic_info *info,
369 ret = max8997_muic_set_path(info, info->path_uart, attached);
371 dev_err(info->dev, "failed to update muic register\n");
375 extcon_set_state_sync(info->edev, EXTCON_JIG, attached);
380 static int max8997_muic_adc_handler(struct max8997_muic_info *info)
387 cable_type = max8997_muic_get_cable_type(info,
392 ret = max8997_muic_handle_usb(info, MAX8997_USB_HOST, attached);
397 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached);
401 ret = max8997_muic_handle_usb(info,
408 ret = max8997_muic_handle_dock(info, cable_type, attached);
413 ret = max8997_muic_handle_jig_uart(info, attached);
444 dev_info(info->dev,
449 dev_err(info->dev,
458 static int max8997_muic_chg_handler(struct max8997_muic_info *info)
464 chg_type = max8997_muic_get_cable_type(info,
471 adc = info->status[0] & STATUS1_ADC_MASK;
475 max8997_muic_handle_usb(info,
480 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
484 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
488 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
492 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
496 dev_err(info->dev,
507 struct max8997_muic_info *info = container_of(work,
512 if (!info->edev)
515 mutex_lock(&info->mutex);
518 if (info->irq == muic_irqs[i].virq)
521 ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1,
522 2, info->status);
524 dev_err(info->dev, "failed to read muic register\n");
525 mutex_unlock(&info->mutex);
534 ret = max8997_muic_adc_handler(info);
542 ret = max8997_muic_chg_handler(info);
547 dev_info(info->dev, "misc interrupt: irq %d occurred\n",
549 mutex_unlock(&info->mutex);
554 dev_err(info->dev, "failed to handle MUIC interrupt\n");
556 mutex_unlock(&info->mutex);
561 struct max8997_muic_info *info = data;
563 dev_dbg(info->dev, "irq:%d\n", irq);
564 info->irq = irq;
566 schedule_work(&info->irq_work);
571 static int max8997_muic_detect_dev(struct max8997_muic_info *info)
578 mutex_lock(&info->mutex);
581 ret = max8997_bulk_read(info->muic,
582 MAX8997_MUIC_REG_STATUS1, 2, info->status);
584 dev_err(info->dev, "failed to read MUIC register\n");
585 mutex_unlock(&info->mutex);
589 adc = max8997_muic_get_cable_type(info, MAX8997_CABLE_GROUP_ADC,
592 ret = max8997_muic_adc_handler(info);
594 dev_err(info->dev, "Cannot detect ADC cable\n");
595 mutex_unlock(&info->mutex);
600 chg_type = max8997_muic_get_cable_type(info, MAX8997_CABLE_GROUP_CHG,
603 ret = max8997_muic_chg_handler(info);
605 dev_err(info->dev, "Cannot detect charger cable\n");
606 mutex_unlock(&info->mutex);
611 mutex_unlock(&info->mutex);
618 struct max8997_muic_info *info = container_of(to_delayed_work(work),
622 ret = max8997_muic_detect_dev(info);
624 dev_err(info->dev, "failed to detect cable type\n");
631 struct max8997_muic_info *info;
637 info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info),
639 if (!info)
642 info->dev = &pdev->dev;
643 info->muic = max8997->muic;
645 platform_set_drvdata(pdev, info);
646 mutex_init(&info->mutex);
648 INIT_WORK(&info->irq_work, max8997_muic_irq_work);
664 muic_irq->name, info);
674 info->edev = devm_extcon_dev_allocate(&pdev->dev, max8997_extcon_cable);
675 if (IS_ERR(info->edev)) {
677 ret = PTR_ERR(info->edev);
681 ret = devm_extcon_dev_register(&pdev->dev, info->edev);
693 max8997_write_reg(info->muic,
703 info->path_uart = muic_pdata->path_uart;
705 info->path_uart = CONTROL1_SW_UART;
708 info->path_usb = muic_pdata->path_usb;
710 info->path_usb = CONTROL1_SW_USB;
722 info->path_uart = CONTROL1_SW_UART;
723 info->path_usb = CONTROL1_SW_USB;
728 ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1,
729 2, info->status);
731 dev_err(info->dev, "failed to read MUIC register\n");
734 cable_type = max8997_muic_get_cable_type(info,
737 max8997_muic_set_path(info, info->path_uart, true);
740 max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
750 INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq);
751 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,
758 free_irq(muic_irqs[i].virq, info);
764 struct max8997_muic_info *info = platform_get_drvdata(pdev);
768 free_irq(muic_irqs[i].virq, info);
769 cancel_work_sync(&info->irq_work);