Lines Matching refs:info

225 static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,  in max77693_muic_set_debounce_time()  argument
240 ret = regmap_write(info->max77693->regmap_muic, in max77693_muic_set_debounce_time()
244 dev_err(info->dev, "failed to set ADC debounce time\n"); in max77693_muic_set_debounce_time()
249 dev_err(info->dev, "invalid ADC debounce time\n"); in max77693_muic_set_debounce_time()
266 static int max77693_muic_set_path(struct max77693_muic_info *info, in max77693_muic_set_path() argument
277 ret = regmap_update_bits(info->max77693->regmap_muic, in max77693_muic_set_path()
280 dev_err(info->dev, "failed to update MUIC register\n"); in max77693_muic_set_path()
289 ret = regmap_update_bits(info->max77693->regmap_muic, in max77693_muic_set_path()
294 dev_err(info->dev, "failed to update MUIC register\n"); in max77693_muic_set_path()
298 dev_info(info->dev, in max77693_muic_set_path()
318 static int max77693_muic_get_cable_type(struct max77693_muic_info *info, in max77693_muic_get_cable_type() argument
334 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK; in max77693_muic_get_cable_type()
345 cable_type = info->prev_cable_type; in max77693_muic_get_cable_type()
346 info->prev_cable_type = MAX77693_MUIC_ADC_OPEN; in max77693_muic_get_cable_type()
350 cable_type = info->prev_cable_type = adc; in max77693_muic_get_cable_type()
358 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK; in max77693_muic_get_cable_type()
369 cable_type = info->prev_cable_type_gnd; in max77693_muic_get_cable_type()
370 info->prev_cable_type_gnd = MAX77693_MUIC_ADC_OPEN; in max77693_muic_get_cable_type()
374 adclow = info->status[0] & MAX77693_STATUS1_ADCLOW_MASK; in max77693_muic_get_cable_type()
376 adc1k = info->status[0] & MAX77693_STATUS1_ADC1K_MASK; in max77693_muic_get_cable_type()
379 vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK; in max77693_muic_get_cable_type()
395 info->prev_cable_type = adc; in max77693_muic_get_cable_type()
396 info->prev_cable_type_gnd = cable_type; in max77693_muic_get_cable_type()
405 chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK; in max77693_muic_get_cable_type()
411 cable_type = info->prev_chg_type; in max77693_muic_get_cable_type()
412 info->prev_chg_type = MAX77693_CHARGER_TYPE_NONE; in max77693_muic_get_cable_type()
421 cable_type = info->prev_chg_type = chg_type; in max77693_muic_get_cable_type()
430 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK; in max77693_muic_get_cable_type()
432 chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK; in max77693_muic_get_cable_type()
445 vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK; in max77693_muic_get_cable_type()
451 dev_err(info->dev, "Unknown cable group (%d)\n", group); in max77693_muic_get_cable_type()
459 static int max77693_muic_dock_handler(struct max77693_muic_info *info, in max77693_muic_dock_handler() argument
467 dev_info(info->dev, in max77693_muic_dock_handler()
479 vbvolt = max77693_muic_get_cable_type(info, in max77693_muic_dock_handler()
482 dev_warn(info->dev, in max77693_muic_dock_handler()
506 ret = max77693_muic_set_path(info, info->path_usb, attached); in max77693_muic_dock_handler()
510 extcon_set_state_sync(info->edev, EXTCON_DOCK, attached); in max77693_muic_dock_handler()
511 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); in max77693_muic_dock_handler()
519 extcon_set_state_sync(info->edev, EXTCON_USB, false); in max77693_muic_dock_handler()
520 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_dock_handler()
525 dev_err(info->dev, "failed to detect %s dock device\n", in max77693_muic_dock_handler()
531 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO, in max77693_muic_dock_handler()
535 extcon_set_state_sync(info->edev, dock_id, attached); in max77693_muic_dock_handler()
541 static int max77693_muic_dock_button_handler(struct max77693_muic_info *info, in max77693_muic_dock_button_handler() argument
544 struct input_dev *dock = info->dock; in max77693_muic_dock_button_handler()
572 dev_err(info->dev, in max77693_muic_dock_button_handler()
584 static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) in max77693_muic_adc_ground_handler() argument
590 cable_type_gnd = max77693_muic_get_cable_type(info, in max77693_muic_adc_ground_handler()
597 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_USB, in max77693_muic_adc_ground_handler()
601 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); in max77693_muic_adc_ground_handler()
605 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO, in max77693_muic_adc_ground_handler()
609 extcon_set_state_sync(info->edev, EXTCON_USB, attached); in max77693_muic_adc_ground_handler()
610 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_adc_ground_handler()
616 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); in max77693_muic_adc_ground_handler()
619 dev_err(info->dev, "failed to detect %s cable of gnd type\n", in max77693_muic_adc_ground_handler()
627 static int max77693_muic_jig_handler(struct max77693_muic_info *info, in max77693_muic_jig_handler() argument
633 dev_info(info->dev, in max77693_muic_jig_handler()
649 dev_err(info->dev, "failed to detect %s jig cable\n", in max77693_muic_jig_handler()
654 ret = max77693_muic_set_path(info, path, attached); in max77693_muic_jig_handler()
658 extcon_set_state_sync(info->edev, EXTCON_JIG, attached); in max77693_muic_jig_handler()
663 static int max77693_muic_adc_handler(struct max77693_muic_info *info) in max77693_muic_adc_handler() argument
671 cable_type = max77693_muic_get_cable_type(info, in max77693_muic_adc_handler()
674 dev_info(info->dev, in max77693_muic_adc_handler()
677 info->prev_cable_type); in max77693_muic_adc_handler()
682 max77693_muic_adc_ground_handler(info); in max77693_muic_adc_handler()
689 ret = max77693_muic_jig_handler(info, cable_type, attached); in max77693_muic_adc_handler()
705 ret = max77693_muic_dock_handler(info, cable_type, attached); in max77693_muic_adc_handler()
725 button_type = info->prev_button_type = cable_type; in max77693_muic_adc_handler()
727 button_type = info->prev_button_type; in max77693_muic_adc_handler()
729 ret = max77693_muic_dock_button_handler(info, button_type, in max77693_muic_adc_handler()
757 dev_info(info->dev, in max77693_muic_adc_handler()
762 dev_err(info->dev, in max77693_muic_adc_handler()
771 static int max77693_muic_chg_handler(struct max77693_muic_info *info) in max77693_muic_chg_handler() argument
780 chg_type = max77693_muic_get_cable_type(info, in max77693_muic_chg_handler()
783 dev_info(info->dev, in max77693_muic_chg_handler()
786 chg_type, info->prev_chg_type); in max77693_muic_chg_handler()
793 cable_type_gnd = max77693_muic_get_cable_type(info, in max77693_muic_chg_handler()
812 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77693_muic_chg_handler()
814 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, in max77693_muic_chg_handler()
820 cable_type = max77693_muic_get_cable_type(info, in max77693_muic_chg_handler()
838 extcon_set_state_sync(info->edev, EXTCON_USB, in max77693_muic_chg_handler()
840 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_chg_handler()
844 extcon_set_state_sync(info->edev, EXTCON_DOCK, in max77693_muic_chg_handler()
868 ret = max77693_muic_set_path(info, info->path_usb, in max77693_muic_chg_handler()
873 extcon_set_state_sync(info->edev, EXTCON_DOCK, in max77693_muic_chg_handler()
875 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, in max77693_muic_chg_handler()
904 ret = max77693_muic_set_path(info, info->path_usb, in max77693_muic_chg_handler()
909 extcon_set_state_sync(info->edev, EXTCON_USB, in max77693_muic_chg_handler()
911 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_chg_handler()
916 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77693_muic_chg_handler()
922 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP, in max77693_muic_chg_handler()
926 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW, in max77693_muic_chg_handler()
930 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST, in max77693_muic_chg_handler()
936 dev_err(info->dev, in max77693_muic_chg_handler()
947 struct max77693_muic_info *info = container_of(work, in max77693_muic_irq_work() local
952 if (!info->edev) in max77693_muic_irq_work()
955 mutex_lock(&info->mutex); in max77693_muic_irq_work()
958 if (info->irq == muic_irqs[i].virq) in max77693_muic_irq_work()
961 ret = regmap_bulk_read(info->max77693->regmap_muic, in max77693_muic_irq_work()
962 MAX77693_MUIC_REG_STATUS1, info->status, 2); in max77693_muic_irq_work()
964 dev_err(info->dev, "failed to read MUIC register\n"); in max77693_muic_irq_work()
965 mutex_unlock(&info->mutex); in max77693_muic_irq_work()
978 ret = max77693_muic_adc_handler(info); in max77693_muic_irq_work()
987 ret = max77693_muic_chg_handler(info); in max77693_muic_irq_work()
997 dev_err(info->dev, "muic interrupt: irq %d occurred\n", in max77693_muic_irq_work()
999 mutex_unlock(&info->mutex); in max77693_muic_irq_work()
1004 dev_err(info->dev, "failed to handle MUIC interrupt\n"); in max77693_muic_irq_work()
1006 mutex_unlock(&info->mutex); in max77693_muic_irq_work()
1011 struct max77693_muic_info *info = data; in max77693_muic_irq_handler() local
1013 info->irq = irq; in max77693_muic_irq_handler()
1014 schedule_work(&info->irq_work); in max77693_muic_irq_handler()
1024 static int max77693_muic_detect_accessory(struct max77693_muic_info *info) in max77693_muic_detect_accessory() argument
1031 mutex_lock(&info->mutex); in max77693_muic_detect_accessory()
1034 ret = regmap_bulk_read(info->max77693->regmap_muic, in max77693_muic_detect_accessory()
1035 MAX77693_MUIC_REG_STATUS1, info->status, 2); in max77693_muic_detect_accessory()
1037 dev_err(info->dev, "failed to read MUIC register\n"); in max77693_muic_detect_accessory()
1038 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1042 adc = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_ADC, in max77693_muic_detect_accessory()
1045 ret = max77693_muic_adc_handler(info); in max77693_muic_detect_accessory()
1047 dev_err(info->dev, "Cannot detect accessory\n"); in max77693_muic_detect_accessory()
1048 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1053 chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG, in max77693_muic_detect_accessory()
1056 ret = max77693_muic_chg_handler(info); in max77693_muic_detect_accessory()
1058 dev_err(info->dev, "Cannot detect charger accessory\n"); in max77693_muic_detect_accessory()
1059 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1064 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1071 struct max77693_muic_info *info = container_of(to_delayed_work(work), in max77693_muic_detect_cable_wq() local
1074 max77693_muic_detect_accessory(info); in max77693_muic_detect_cable_wq()
1081 struct max77693_muic_info *info; in max77693_muic_probe() local
1089 info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info), in max77693_muic_probe()
1091 if (!info) in max77693_muic_probe()
1094 info->dev = &pdev->dev; in max77693_muic_probe()
1095 info->max77693 = max77693; in max77693_muic_probe()
1096 if (info->max77693->regmap_muic) { in max77693_muic_probe()
1099 info->max77693->regmap_muic = devm_regmap_init_i2c( in max77693_muic_probe()
1100 info->max77693->i2c_muic, in max77693_muic_probe()
1102 if (IS_ERR(info->max77693->regmap_muic)) { in max77693_muic_probe()
1103 ret = PTR_ERR(info->max77693->regmap_muic); in max77693_muic_probe()
1111 info->dock = devm_input_allocate_device(&pdev->dev); in max77693_muic_probe()
1112 if (!info->dock) { in max77693_muic_probe()
1116 info->dock->name = "max77693-muic/dock"; in max77693_muic_probe()
1117 info->dock->phys = "max77693-muic/extcon"; in max77693_muic_probe()
1118 info->dock->dev.parent = &pdev->dev; in max77693_muic_probe()
1120 __set_bit(EV_REP, info->dock->evbit); in max77693_muic_probe()
1122 input_set_capability(info->dock, EV_KEY, KEY_VOLUMEUP); in max77693_muic_probe()
1123 input_set_capability(info->dock, EV_KEY, KEY_VOLUMEDOWN); in max77693_muic_probe()
1124 input_set_capability(info->dock, EV_KEY, KEY_PLAYPAUSE); in max77693_muic_probe()
1125 input_set_capability(info->dock, EV_KEY, KEY_PREVIOUSSONG); in max77693_muic_probe()
1126 input_set_capability(info->dock, EV_KEY, KEY_NEXTSONG); in max77693_muic_probe()
1128 ret = input_register_device(info->dock); in max77693_muic_probe()
1135 platform_set_drvdata(pdev, info); in max77693_muic_probe()
1136 mutex_init(&info->mutex); in max77693_muic_probe()
1138 INIT_WORK(&info->irq_work, max77693_muic_irq_work); in max77693_muic_probe()
1154 muic_irq->name, info); in max77693_muic_probe()
1164 info->edev = devm_extcon_dev_allocate(&pdev->dev, in max77693_muic_probe()
1166 if (IS_ERR(info->edev)) { in max77693_muic_probe()
1171 ret = devm_extcon_dev_register(&pdev->dev, info->edev); in max77693_muic_probe()
1187 regmap_write(info->max77693->regmap_muic, in max77693_muic_probe()
1201 info->path_uart = muic_pdata->path_uart; in max77693_muic_probe()
1203 info->path_uart = MAX77693_CONTROL1_SW_UART; in max77693_muic_probe()
1206 info->path_usb = muic_pdata->path_usb; in max77693_muic_probe()
1208 info->path_usb = MAX77693_CONTROL1_SW_USB; in max77693_muic_probe()
1220 info->path_usb = MAX77693_CONTROL1_SW_USB; in max77693_muic_probe()
1221 info->path_uart = MAX77693_CONTROL1_SW_UART; in max77693_muic_probe()
1226 max77693_muic_set_path(info, info->path_uart, true); in max77693_muic_probe()
1229 ret = regmap_read(info->max77693->regmap_muic, in max77693_muic_probe()
1235 dev_info(info->dev, "device ID : 0x%x\n", id); in max77693_muic_probe()
1238 max77693_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); in max77693_muic_probe()
1248 INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq); in max77693_muic_probe()
1249 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, in max77693_muic_probe()
1257 struct max77693_muic_info *info = platform_get_drvdata(pdev); in max77693_muic_remove() local
1259 cancel_work_sync(&info->irq_work); in max77693_muic_remove()
1260 input_unregister_device(info->dock); in max77693_muic_remove()