Lines Matching refs:info
157 * @info: the instance including private data of max8997 MUIC
160 static int max8997_muic_set_debounce_time(struct max8997_muic_info *info,
170 ret = max8997_update_reg(info->muic,
175 dev_err(info->dev, "failed to set ADC debounce time\n");
180 dev_err(info->dev, "invalid ADC debounce time\n");
189 * @info: the instance including private data of max8997 MUIC
197 static int max8997_muic_set_path(struct max8997_muic_info *info,
208 ret = max8997_update_reg(info->muic,
211 dev_err(info->dev, "failed to update MUIC register\n");
220 ret = max8997_update_reg(info->muic,
224 dev_err(info->dev, "failed to update MUIC register\n");
228 dev_info(info->dev,
237 * @info: the instance including private data of max8997 MUIC
246 static int max8997_muic_get_cable_type(struct max8997_muic_info *info,
259 adc = info->status[0] & STATUS1_ADC_MASK;
264 * (info->prev_cable_type) for handling cable when cable is
270 cable_type = info->prev_cable_type;
271 info->prev_cable_type = MAX8997_MUIC_ADC_OPEN;
275 cable_type = info->prev_cable_type = adc;
283 chg_type = info->status[1] & STATUS2_CHGTYP_MASK;
289 cable_type = info->prev_chg_type;
290 info->prev_chg_type = MAX8997_CHARGER_TYPE_NONE;
296 * type(info->prev_chg_type) for handling cable when
299 cable_type = info->prev_chg_type = chg_type;
304 dev_err(info->dev, "Unknown cable group (%d)\n", group);
312 static int max8997_muic_handle_usb(struct max8997_muic_info *info,
317 ret = max8997_muic_set_path(info, info->path_usb, attached);
319 dev_err(info->dev, "failed to update muic register\n");
325 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached);
328 extcon_set_state_sync(info->edev, EXTCON_USB, attached);
329 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP,
333 dev_err(info->dev, "failed to detect %s usb cable\n",
341 static int max8997_muic_handle_dock(struct max8997_muic_info *info,
346 ret = max8997_muic_set_path(info, CONTROL1_SW_AUDIO, attached);
348 dev_err(info->dev, "failed to update muic register\n");
355 extcon_set_state_sync(info->edev, EXTCON_DOCK, attached);
358 dev_err(info->dev, "failed to detect %s dock device\n",
366 static int max8997_muic_handle_jig_uart(struct max8997_muic_info *info,
372 ret = max8997_muic_set_path(info, info->path_uart, attached);
374 dev_err(info->dev, "failed to update muic register\n");
378 extcon_set_state_sync(info->edev, EXTCON_JIG, attached);
383 static int max8997_muic_adc_handler(struct max8997_muic_info *info)
390 cable_type = max8997_muic_get_cable_type(info,
395 ret = max8997_muic_handle_usb(info, MAX8997_USB_HOST, attached);
400 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached);
404 ret = max8997_muic_handle_usb(info,
411 ret = max8997_muic_handle_dock(info, cable_type, attached);
416 ret = max8997_muic_handle_jig_uart(info, attached);
447 dev_info(info->dev,
452 dev_err(info->dev,
461 static int max8997_muic_chg_handler(struct max8997_muic_info *info)
467 chg_type = max8997_muic_get_cable_type(info,
474 adc = info->status[0] & STATUS1_ADC_MASK;
478 max8997_muic_handle_usb(info,
483 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP,
487 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP,
491 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW,
495 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST,
499 dev_err(info->dev,
510 struct max8997_muic_info *info = container_of(work,
515 if (!info->edev)
518 mutex_lock(&info->mutex);
521 if (info->irq == muic_irqs[i].virq)
524 ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1,
525 2, info->status);
527 dev_err(info->dev, "failed to read muic register\n");
528 mutex_unlock(&info->mutex);
537 ret = max8997_muic_adc_handler(info);
547 ret = max8997_muic_chg_handler(info);
552 dev_info(info->dev, "misc interrupt: irq %d occurred\n",
554 mutex_unlock(&info->mutex);
559 dev_err(info->dev, "failed to handle MUIC interrupt\n");
561 mutex_unlock(&info->mutex);
566 struct max8997_muic_info *info = data;
568 dev_dbg(info->dev, "irq:%d\n", irq);
569 info->irq = irq;
571 schedule_work(&info->irq_work);
576 static int max8997_muic_detect_dev(struct max8997_muic_info *info)
583 mutex_lock(&info->mutex);
586 ret = max8997_bulk_read(info->muic,
587 MAX8997_MUIC_REG_STATUS1, 2, info->status);
589 dev_err(info->dev, "failed to read MUIC register\n");
590 mutex_unlock(&info->mutex);
594 adc = max8997_muic_get_cable_type(info, MAX8997_CABLE_GROUP_ADC,
597 ret = max8997_muic_adc_handler(info);
599 dev_err(info->dev, "Cannot detect ADC cable\n");
600 mutex_unlock(&info->mutex);
605 chg_type = max8997_muic_get_cable_type(info, MAX8997_CABLE_GROUP_CHG,
608 ret = max8997_muic_chg_handler(info);
610 dev_err(info->dev, "Cannot detect charger cable\n");
611 mutex_unlock(&info->mutex);
616 mutex_unlock(&info->mutex);
623 struct max8997_muic_info *info = container_of(to_delayed_work(work),
627 ret = max8997_muic_detect_dev(info);
629 dev_err(info->dev, "failed to detect cable type\n");
636 struct max8997_muic_info *info;
642 info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info),
644 if (!info)
647 info->dev = &pdev->dev;
648 info->muic = max8997->muic;
650 platform_set_drvdata(pdev, info);
651 mutex_init(&info->mutex);
653 INIT_WORK(&info->irq_work, max8997_muic_irq_work);
654 ret = devm_work_autocancel(&pdev->dev, &info->irq_work,
672 muic_irq->name, info);
682 info->edev = devm_extcon_dev_allocate(&pdev->dev, max8997_extcon_cable);
683 if (IS_ERR(info->edev)) {
685 return PTR_ERR(info->edev);
688 ret = devm_extcon_dev_register(&pdev->dev, info->edev);
700 max8997_write_reg(info->muic,
710 info->path_uart = muic_pdata->path_uart;
712 info->path_uart = CONTROL1_SW_UART;
715 info->path_usb = muic_pdata->path_usb;
717 info->path_usb = CONTROL1_SW_USB;
729 info->path_uart = CONTROL1_SW_UART;
730 info->path_usb = CONTROL1_SW_USB;
735 ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1,
736 2, info->status);
738 dev_err(info->dev, "failed to read MUIC register\n");
741 cable_type = max8997_muic_get_cable_type(info,
744 max8997_muic_set_path(info, info->path_uart, true);
747 max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
757 INIT_DELAYED_WORK(&info->wq_detcable, max8997_muic_detect_cable_wq);
758 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable,