Lines Matching refs:info
216 static int max77693_muic_set_debounce_time(struct max77693_muic_info *info, in max77693_muic_set_debounce_time() argument
231 ret = regmap_write(info->max77693->regmap_muic, in max77693_muic_set_debounce_time()
235 dev_err(info->dev, "failed to set ADC debounce time\n"); in max77693_muic_set_debounce_time()
240 dev_err(info->dev, "invalid ADC debounce time\n"); in max77693_muic_set_debounce_time()
257 static int max77693_muic_set_path(struct max77693_muic_info *info, in max77693_muic_set_path() argument
268 ret = regmap_update_bits(info->max77693->regmap_muic, in max77693_muic_set_path()
271 dev_err(info->dev, "failed to update MUIC register\n"); in max77693_muic_set_path()
280 ret = regmap_update_bits(info->max77693->regmap_muic, in max77693_muic_set_path()
285 dev_err(info->dev, "failed to update MUIC register\n"); in max77693_muic_set_path()
289 dev_info(info->dev, in max77693_muic_set_path()
309 static int max77693_muic_get_cable_type(struct max77693_muic_info *info, in max77693_muic_get_cable_type() argument
325 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK; in max77693_muic_get_cable_type()
336 cable_type = info->prev_cable_type; in max77693_muic_get_cable_type()
337 info->prev_cable_type = MAX77693_MUIC_ADC_OPEN; in max77693_muic_get_cable_type()
341 cable_type = info->prev_cable_type = adc; in max77693_muic_get_cable_type()
349 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK; in max77693_muic_get_cable_type()
360 cable_type = info->prev_cable_type_gnd; in max77693_muic_get_cable_type()
361 info->prev_cable_type_gnd = MAX77693_MUIC_ADC_OPEN; in max77693_muic_get_cable_type()
365 adclow = info->status[0] & MAX77693_STATUS1_ADCLOW_MASK; in max77693_muic_get_cable_type()
367 adc1k = info->status[0] & MAX77693_STATUS1_ADC1K_MASK; in max77693_muic_get_cable_type()
370 vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK; in max77693_muic_get_cable_type()
386 info->prev_cable_type = adc; in max77693_muic_get_cable_type()
387 info->prev_cable_type_gnd = cable_type; in max77693_muic_get_cable_type()
396 chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK; in max77693_muic_get_cable_type()
402 cable_type = info->prev_chg_type; in max77693_muic_get_cable_type()
403 info->prev_chg_type = MAX77693_CHARGER_TYPE_NONE; in max77693_muic_get_cable_type()
412 cable_type = info->prev_chg_type = chg_type; in max77693_muic_get_cable_type()
421 adc = info->status[0] & MAX77693_STATUS1_ADC_MASK; in max77693_muic_get_cable_type()
423 chg_type = info->status[1] & MAX77693_STATUS2_CHGTYP_MASK; in max77693_muic_get_cable_type()
436 vbvolt = info->status[1] & MAX77693_STATUS2_VBVOLT_MASK; in max77693_muic_get_cable_type()
442 dev_err(info->dev, "Unknown cable group (%d)\n", group); in max77693_muic_get_cable_type()
450 static int max77693_muic_dock_handler(struct max77693_muic_info *info, in max77693_muic_dock_handler() argument
458 dev_info(info->dev, in max77693_muic_dock_handler()
470 vbvolt = max77693_muic_get_cable_type(info, in max77693_muic_dock_handler()
473 dev_warn(info->dev, in max77693_muic_dock_handler()
497 ret = max77693_muic_set_path(info, info->path_usb, attached); in max77693_muic_dock_handler()
501 extcon_set_state_sync(info->edev, EXTCON_DOCK, attached); in max77693_muic_dock_handler()
502 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); in max77693_muic_dock_handler()
510 extcon_set_state_sync(info->edev, EXTCON_USB, false); in max77693_muic_dock_handler()
511 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_dock_handler()
516 dev_err(info->dev, "failed to detect %s dock device\n", in max77693_muic_dock_handler()
522 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO, in max77693_muic_dock_handler()
526 extcon_set_state_sync(info->edev, dock_id, attached); in max77693_muic_dock_handler()
532 static int max77693_muic_dock_button_handler(struct max77693_muic_info *info, in max77693_muic_dock_button_handler() argument
535 struct input_dev *dock = info->dock; in max77693_muic_dock_button_handler()
563 dev_err(info->dev, in max77693_muic_dock_button_handler()
575 static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) in max77693_muic_adc_ground_handler() argument
581 cable_type_gnd = max77693_muic_get_cable_type(info, in max77693_muic_adc_ground_handler()
588 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_USB, in max77693_muic_adc_ground_handler()
592 extcon_set_state_sync(info->edev, EXTCON_USB_HOST, attached); in max77693_muic_adc_ground_handler()
596 ret = max77693_muic_set_path(info, MAX77693_CONTROL1_SW_AUDIO, in max77693_muic_adc_ground_handler()
600 extcon_set_state_sync(info->edev, EXTCON_USB, attached); in max77693_muic_adc_ground_handler()
601 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_adc_ground_handler()
607 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, attached); in max77693_muic_adc_ground_handler()
610 dev_err(info->dev, "failed to detect %s cable of gnd type\n", in max77693_muic_adc_ground_handler()
618 static int max77693_muic_jig_handler(struct max77693_muic_info *info, in max77693_muic_jig_handler() argument
624 dev_info(info->dev, in max77693_muic_jig_handler()
640 dev_err(info->dev, "failed to detect %s jig cable\n", in max77693_muic_jig_handler()
645 ret = max77693_muic_set_path(info, path, attached); in max77693_muic_jig_handler()
649 extcon_set_state_sync(info->edev, EXTCON_JIG, attached); in max77693_muic_jig_handler()
654 static int max77693_muic_adc_handler(struct max77693_muic_info *info) in max77693_muic_adc_handler() argument
662 cable_type = max77693_muic_get_cable_type(info, in max77693_muic_adc_handler()
665 dev_info(info->dev, in max77693_muic_adc_handler()
668 info->prev_cable_type); in max77693_muic_adc_handler()
673 max77693_muic_adc_ground_handler(info); in max77693_muic_adc_handler()
680 ret = max77693_muic_jig_handler(info, cable_type, attached); in max77693_muic_adc_handler()
696 ret = max77693_muic_dock_handler(info, cable_type, attached); in max77693_muic_adc_handler()
716 button_type = info->prev_button_type = cable_type; in max77693_muic_adc_handler()
718 button_type = info->prev_button_type; in max77693_muic_adc_handler()
720 ret = max77693_muic_dock_button_handler(info, button_type, in max77693_muic_adc_handler()
748 dev_info(info->dev, in max77693_muic_adc_handler()
753 dev_err(info->dev, in max77693_muic_adc_handler()
762 static int max77693_muic_chg_handler(struct max77693_muic_info *info) in max77693_muic_chg_handler() argument
771 chg_type = max77693_muic_get_cable_type(info, in max77693_muic_chg_handler()
774 dev_info(info->dev, in max77693_muic_chg_handler()
777 chg_type, info->prev_chg_type); in max77693_muic_chg_handler()
784 cable_type_gnd = max77693_muic_get_cable_type(info, in max77693_muic_chg_handler()
803 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77693_muic_chg_handler()
805 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, in max77693_muic_chg_handler()
811 cable_type = max77693_muic_get_cable_type(info, in max77693_muic_chg_handler()
829 extcon_set_state_sync(info->edev, EXTCON_USB, in max77693_muic_chg_handler()
831 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_chg_handler()
835 extcon_set_state_sync(info->edev, EXTCON_DOCK, in max77693_muic_chg_handler()
859 ret = max77693_muic_set_path(info, info->path_usb, in max77693_muic_chg_handler()
864 extcon_set_state_sync(info->edev, EXTCON_DOCK, in max77693_muic_chg_handler()
866 extcon_set_state_sync(info->edev, EXTCON_DISP_MHL, in max77693_muic_chg_handler()
895 ret = max77693_muic_set_path(info, info->path_usb, in max77693_muic_chg_handler()
900 extcon_set_state_sync(info->edev, EXTCON_USB, in max77693_muic_chg_handler()
902 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SDP, in max77693_muic_chg_handler()
907 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_DCP, in max77693_muic_chg_handler()
913 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_CDP, in max77693_muic_chg_handler()
917 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_SLOW, in max77693_muic_chg_handler()
921 extcon_set_state_sync(info->edev, EXTCON_CHG_USB_FAST, in max77693_muic_chg_handler()
927 dev_err(info->dev, in max77693_muic_chg_handler()
938 struct max77693_muic_info *info = container_of(work, in max77693_muic_irq_work() local
943 if (!info->edev) in max77693_muic_irq_work()
946 mutex_lock(&info->mutex); in max77693_muic_irq_work()
949 if (info->irq == muic_irqs[i].virq) in max77693_muic_irq_work()
952 ret = regmap_bulk_read(info->max77693->regmap_muic, in max77693_muic_irq_work()
953 MAX77693_MUIC_REG_STATUS1, info->status, 2); in max77693_muic_irq_work()
955 dev_err(info->dev, "failed to read MUIC register\n"); in max77693_muic_irq_work()
956 mutex_unlock(&info->mutex); in max77693_muic_irq_work()
969 ret = max77693_muic_adc_handler(info); in max77693_muic_irq_work()
978 ret = max77693_muic_chg_handler(info); in max77693_muic_irq_work()
988 dev_err(info->dev, "muic interrupt: irq %d occurred\n", in max77693_muic_irq_work()
990 mutex_unlock(&info->mutex); in max77693_muic_irq_work()
995 dev_err(info->dev, "failed to handle MUIC interrupt\n"); in max77693_muic_irq_work()
997 mutex_unlock(&info->mutex); in max77693_muic_irq_work()
1002 struct max77693_muic_info *info = data; in max77693_muic_irq_handler() local
1004 info->irq = irq; in max77693_muic_irq_handler()
1005 schedule_work(&info->irq_work); in max77693_muic_irq_handler()
1015 static int max77693_muic_detect_accessory(struct max77693_muic_info *info) in max77693_muic_detect_accessory() argument
1022 mutex_lock(&info->mutex); in max77693_muic_detect_accessory()
1025 ret = regmap_bulk_read(info->max77693->regmap_muic, in max77693_muic_detect_accessory()
1026 MAX77693_MUIC_REG_STATUS1, info->status, 2); in max77693_muic_detect_accessory()
1028 dev_err(info->dev, "failed to read MUIC register\n"); in max77693_muic_detect_accessory()
1029 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1033 adc = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_ADC, in max77693_muic_detect_accessory()
1036 ret = max77693_muic_adc_handler(info); in max77693_muic_detect_accessory()
1038 dev_err(info->dev, "Cannot detect accessory\n"); in max77693_muic_detect_accessory()
1039 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1044 chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG, in max77693_muic_detect_accessory()
1047 ret = max77693_muic_chg_handler(info); in max77693_muic_detect_accessory()
1049 dev_err(info->dev, "Cannot detect charger accessory\n"); in max77693_muic_detect_accessory()
1050 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1055 mutex_unlock(&info->mutex); in max77693_muic_detect_accessory()
1062 struct max77693_muic_info *info = container_of(to_delayed_work(work), in max77693_muic_detect_cable_wq() local
1065 max77693_muic_detect_accessory(info); in max77693_muic_detect_cable_wq()
1072 struct max77693_muic_info *info; in max77693_muic_probe() local
1082 info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info), in max77693_muic_probe()
1084 if (!info) in max77693_muic_probe()
1087 info->dev = &pdev->dev; in max77693_muic_probe()
1088 info->max77693 = max77693; in max77693_muic_probe()
1089 if (info->max77693->regmap_muic) { in max77693_muic_probe()
1092 info->max77693->regmap_muic = devm_regmap_init_i2c( in max77693_muic_probe()
1093 info->max77693->i2c_muic, in max77693_muic_probe()
1095 if (IS_ERR(info->max77693->regmap_muic)) { in max77693_muic_probe()
1096 ret = PTR_ERR(info->max77693->regmap_muic); in max77693_muic_probe()
1104 info->dock = devm_input_allocate_device(&pdev->dev); in max77693_muic_probe()
1105 if (!info->dock) { in max77693_muic_probe()
1109 info->dock->name = "max77693-muic/dock"; in max77693_muic_probe()
1110 info->dock->phys = "max77693-muic/extcon"; in max77693_muic_probe()
1111 info->dock->dev.parent = &pdev->dev; in max77693_muic_probe()
1113 __set_bit(EV_REP, info->dock->evbit); in max77693_muic_probe()
1115 input_set_capability(info->dock, EV_KEY, KEY_VOLUMEUP); in max77693_muic_probe()
1116 input_set_capability(info->dock, EV_KEY, KEY_VOLUMEDOWN); in max77693_muic_probe()
1117 input_set_capability(info->dock, EV_KEY, KEY_PLAYPAUSE); in max77693_muic_probe()
1118 input_set_capability(info->dock, EV_KEY, KEY_PREVIOUSSONG); in max77693_muic_probe()
1119 input_set_capability(info->dock, EV_KEY, KEY_NEXTSONG); in max77693_muic_probe()
1121 ret = input_register_device(info->dock); in max77693_muic_probe()
1128 platform_set_drvdata(pdev, info); in max77693_muic_probe()
1129 mutex_init(&info->mutex); in max77693_muic_probe()
1131 ret = devm_work_autocancel(&pdev->dev, &info->irq_work, in max77693_muic_probe()
1150 muic_irq->name, info); in max77693_muic_probe()
1160 info->edev = devm_extcon_dev_allocate(&pdev->dev, in max77693_muic_probe()
1162 if (IS_ERR(info->edev)) { in max77693_muic_probe()
1164 return PTR_ERR(info->edev); in max77693_muic_probe()
1167 ret = devm_extcon_dev_register(&pdev->dev, info->edev); in max77693_muic_probe()
1183 regmap_write(info->max77693->regmap_muic, in max77693_muic_probe()
1197 info->path_uart = muic_pdata->path_uart; in max77693_muic_probe()
1199 info->path_uart = MAX77693_CONTROL1_SW_UART; in max77693_muic_probe()
1202 info->path_usb = muic_pdata->path_usb; in max77693_muic_probe()
1204 info->path_usb = MAX77693_CONTROL1_SW_USB; in max77693_muic_probe()
1216 info->path_usb = MAX77693_CONTROL1_SW_USB; in max77693_muic_probe()
1217 info->path_uart = MAX77693_CONTROL1_SW_UART; in max77693_muic_probe()
1222 ret = regmap_bulk_read(info->max77693->regmap_muic, in max77693_muic_probe()
1223 MAX77693_MUIC_REG_STATUS1, info->status, 2); in max77693_muic_probe()
1225 dev_err(info->dev, "failed to read MUIC register\n"); in max77693_muic_probe()
1228 cable_type = max77693_muic_get_cable_type(info, in max77693_muic_probe()
1232 max77693_muic_set_path(info, info->path_uart, true); in max77693_muic_probe()
1235 ret = regmap_read(info->max77693->regmap_muic, in max77693_muic_probe()
1241 dev_info(info->dev, "device ID : 0x%x\n", id); in max77693_muic_probe()
1244 max77693_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS); in max77693_muic_probe()
1254 INIT_DELAYED_WORK(&info->wq_detcable, max77693_muic_detect_cable_wq); in max77693_muic_probe()
1255 queue_delayed_work(system_power_efficient_wq, &info->wq_detcable, in max77693_muic_probe()