Lines Matching refs:info

139 static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)  in axp288_extcon_log_rsi()  argument
145 ret = regmap_read(info->regmap, AXP288_PS_BOOT_REASON_REG, &val); in axp288_extcon_log_rsi()
148 dev_dbg(info->dev, "%s\n", *rsi); in axp288_extcon_log_rsi()
154 regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask); in axp288_extcon_log_rsi()
171 static bool axp288_get_id_pin(struct axp288_extcon_info *info) in axp288_get_id_pin() argument
175 if (info->id_extcon) in axp288_get_id_pin()
176 return extcon_get_state(info->id_extcon, EXTCON_USB_HOST) <= 0; in axp288_get_id_pin()
179 role = usb_role_switch_get_role(info->role_sw); in axp288_get_id_pin()
185 struct axp288_extcon_info *info = in axp288_usb_role_work() local
191 id_pin = axp288_get_id_pin(info); in axp288_usb_role_work()
194 else if (info->vbus_attach) in axp288_usb_role_work()
199 ret = usb_role_switch_set_role(info->role_sw, role); in axp288_usb_role_work()
201 dev_err(info->dev, "failed to set role: %d\n", ret); in axp288_usb_role_work()
204 static bool axp288_get_vbus_attach(struct axp288_extcon_info *info) in axp288_get_vbus_attach() argument
208 ret = regmap_read(info->regmap, AXP288_PS_STAT_REG, &pwr_stat); in axp288_get_vbus_attach()
210 dev_err(info->dev, "failed to read vbus status\n"); in axp288_get_vbus_attach()
217 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) in axp288_handle_chrg_det_event() argument
221 unsigned int cable = info->previous_cable; in axp288_handle_chrg_det_event()
224 vbus_attach = axp288_get_vbus_attach(info); in axp288_handle_chrg_det_event()
229 ret = regmap_read(info->regmap, AXP288_BC_GLOBAL_REG, &cfg); in axp288_handle_chrg_det_event()
233 dev_dbg(info->dev, "can't complete the charger detection\n"); in axp288_handle_chrg_det_event()
237 ret = regmap_read(info->regmap, AXP288_BC_DET_STAT_REG, &stat); in axp288_handle_chrg_det_event()
245 dev_dbg(info->dev, "sdp cable is connected\n"); in axp288_handle_chrg_det_event()
249 dev_dbg(info->dev, "cdp cable is connected\n"); in axp288_handle_chrg_det_event()
253 dev_dbg(info->dev, "dcp cable is connected\n"); in axp288_handle_chrg_det_event()
257 dev_warn(info->dev, "unknown (reserved) bc detect result\n"); in axp288_handle_chrg_det_event()
262 extcon_set_state_sync(info->edev, info->previous_cable, false); in axp288_handle_chrg_det_event()
263 if (info->previous_cable == EXTCON_CHG_USB_SDP) in axp288_handle_chrg_det_event()
264 extcon_set_state_sync(info->edev, EXTCON_USB, false); in axp288_handle_chrg_det_event()
267 extcon_set_state_sync(info->edev, cable, vbus_attach); in axp288_handle_chrg_det_event()
269 extcon_set_state_sync(info->edev, EXTCON_USB, in axp288_handle_chrg_det_event()
272 info->previous_cable = cable; in axp288_handle_chrg_det_event()
275 if (info->role_sw && info->vbus_attach != vbus_attach) { in axp288_handle_chrg_det_event()
276 info->vbus_attach = vbus_attach; in axp288_handle_chrg_det_event()
278 queue_work(system_long_wq, &info->role_work); in axp288_handle_chrg_det_event()
285 dev_err(info->dev, "failed to detect BC Mod\n"); in axp288_handle_chrg_det_event()
293 struct axp288_extcon_info *info = in axp288_extcon_id_evt() local
297 queue_work(system_long_wq, &info->role_work); in axp288_extcon_id_evt()
304 struct axp288_extcon_info *info = data; in axp288_extcon_isr() local
307 ret = axp288_handle_chrg_det_event(info); in axp288_extcon_isr()
309 dev_err(info->dev, "failed to handle the interrupt\n"); in axp288_extcon_isr()
314 static void axp288_extcon_enable(struct axp288_extcon_info *info) in axp288_extcon_enable() argument
316 regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, in axp288_extcon_enable()
319 regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG, in axp288_extcon_enable()
325 struct axp288_extcon_info *info = data; in axp288_put_role_sw() local
327 cancel_work_sync(&info->role_work); in axp288_put_role_sw()
328 usb_role_switch_put(info->role_sw); in axp288_put_role_sw()
333 struct axp288_extcon_info *info; in axp288_extcon_probe() local
339 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in axp288_extcon_probe()
340 if (!info) in axp288_extcon_probe()
343 info->dev = &pdev->dev; in axp288_extcon_probe()
344 info->regmap = axp20x->regmap; in axp288_extcon_probe()
345 info->regmap_irqc = axp20x->regmap_irqc; in axp288_extcon_probe()
346 info->previous_cable = EXTCON_NONE; in axp288_extcon_probe()
347 INIT_WORK(&info->role_work, axp288_usb_role_work); in axp288_extcon_probe()
348 info->id_nb.notifier_call = axp288_extcon_id_evt; in axp288_extcon_probe()
350 platform_set_drvdata(pdev, info); in axp288_extcon_probe()
352 info->role_sw = usb_role_switch_get(dev); in axp288_extcon_probe()
353 if (IS_ERR(info->role_sw)) in axp288_extcon_probe()
354 return PTR_ERR(info->role_sw); in axp288_extcon_probe()
355 if (info->role_sw) { in axp288_extcon_probe()
356 ret = devm_add_action_or_reset(dev, axp288_put_role_sw, info); in axp288_extcon_probe()
362 info->id_extcon = extcon_get_extcon_dev(name); in axp288_extcon_probe()
363 if (!info->id_extcon) in axp288_extcon_probe()
372 info->vbus_attach = axp288_get_vbus_attach(info); in axp288_extcon_probe()
374 axp288_extcon_log_rsi(info); in axp288_extcon_probe()
377 info->edev = devm_extcon_dev_allocate(&pdev->dev, in axp288_extcon_probe()
379 if (IS_ERR(info->edev)) { in axp288_extcon_probe()
381 return PTR_ERR(info->edev); in axp288_extcon_probe()
385 ret = devm_extcon_dev_register(&pdev->dev, info->edev); in axp288_extcon_probe()
396 info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq); in axp288_extcon_probe()
397 if (info->irq[i] < 0) { in axp288_extcon_probe()
400 ret = info->irq[i]; in axp288_extcon_probe()
404 ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], in axp288_extcon_probe()
407 pdev->name, info); in axp288_extcon_probe()
410 info->irq[i]); in axp288_extcon_probe()
415 if (info->id_extcon) { in axp288_extcon_probe()
416 ret = devm_extcon_register_notifier_all(dev, info->id_extcon, in axp288_extcon_probe()
417 &info->id_nb); in axp288_extcon_probe()
423 if (info->role_sw) { in axp288_extcon_probe()
424 queue_work(system_long_wq, &info->role_work); in axp288_extcon_probe()
425 flush_work(&info->role_work); in axp288_extcon_probe()
429 axp288_extcon_enable(info); in axp288_extcon_probe()
432 platform_set_drvdata(pdev, info); in axp288_extcon_probe()
439 struct axp288_extcon_info *info = dev_get_drvdata(dev); in axp288_extcon_suspend() local
442 enable_irq_wake(info->irq[VBUS_RISING_IRQ]); in axp288_extcon_suspend()
449 struct axp288_extcon_info *info = dev_get_drvdata(dev); in axp288_extcon_resume() local
457 disable_irq_wake(info->irq[VBUS_RISING_IRQ]); in axp288_extcon_resume()