• Home
  • Raw
  • Download

Lines Matching refs:info

67 static void sc2731_charger_stop_charge(struct sc2731_charger_info *info)  in sc2731_charger_stop_charge()  argument
69 regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, in sc2731_charger_stop_charge()
72 regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, in sc2731_charger_stop_charge()
76 static int sc2731_charger_start_charge(struct sc2731_charger_info *info) in sc2731_charger_start_charge() argument
81 ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, in sc2731_charger_start_charge()
87 return regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, in sc2731_charger_start_charge()
91 static int sc2731_charger_set_current_limit(struct sc2731_charger_info *info, in sc2731_charger_set_current_limit() argument
105 return regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG5, in sc2731_charger_set_current_limit()
110 static int sc2731_charger_set_current(struct sc2731_charger_info *info, u32 cur) in sc2731_charger_set_current() argument
124 ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, in sc2731_charger_set_current()
130 return regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG1, in sc2731_charger_set_current()
134 static int sc2731_charger_get_status(struct sc2731_charger_info *info) in sc2731_charger_get_status() argument
139 ret = regmap_read(info->regmap, SC2731_CHARGE_STATUS, &val); in sc2731_charger_get_status()
149 static int sc2731_charger_get_current(struct sc2731_charger_info *info, in sc2731_charger_get_current() argument
155 ret = regmap_read(info->regmap, info->base + SC2731_CHG_CFG1, &val); in sc2731_charger_get_current()
165 static int sc2731_charger_get_current_limit(struct sc2731_charger_info *info, in sc2731_charger_get_current_limit() argument
171 ret = regmap_read(info->regmap, info->base + SC2731_CHG_CFG5, &val); in sc2731_charger_get_current_limit()
206 struct sc2731_charger_info *info = power_supply_get_drvdata(psy); in sc2731_charger_usb_set_property() local
209 mutex_lock(&info->lock); in sc2731_charger_usb_set_property()
211 if (!info->charging) { in sc2731_charger_usb_set_property()
212 mutex_unlock(&info->lock); in sc2731_charger_usb_set_property()
218 ret = sc2731_charger_set_current(info, val->intval / 1000); in sc2731_charger_usb_set_property()
220 dev_err(info->dev, "set charge current failed\n"); in sc2731_charger_usb_set_property()
224 ret = sc2731_charger_set_current_limit(info, in sc2731_charger_usb_set_property()
227 dev_err(info->dev, "set input current limit failed\n"); in sc2731_charger_usb_set_property()
234 mutex_unlock(&info->lock); in sc2731_charger_usb_set_property()
242 struct sc2731_charger_info *info = power_supply_get_drvdata(psy); in sc2731_charger_usb_get_property() local
246 mutex_lock(&info->lock); in sc2731_charger_usb_get_property()
250 if (info->charging) in sc2731_charger_usb_get_property()
251 val->intval = sc2731_charger_get_status(info); in sc2731_charger_usb_get_property()
257 if (!info->charging) { in sc2731_charger_usb_get_property()
260 ret = sc2731_charger_get_current(info, &cur); in sc2731_charger_usb_get_property()
269 if (!info->charging) { in sc2731_charger_usb_get_property()
272 ret = sc2731_charger_get_current_limit(info, &cur); in sc2731_charger_usb_get_property()
285 mutex_unlock(&info->lock); in sc2731_charger_usb_get_property()
325 struct sc2731_charger_info *info = in sc2731_charger_work() local
329 mutex_lock(&info->lock); in sc2731_charger_work()
331 if (info->limit > 0 && !info->charging) { in sc2731_charger_work()
333 ret = sc2731_charger_set_current_limit(info, info->limit); in sc2731_charger_work()
337 ret = sc2731_charger_set_current(info, info->limit); in sc2731_charger_work()
341 ret = sc2731_charger_start_charge(info); in sc2731_charger_work()
345 info->charging = true; in sc2731_charger_work()
346 } else if (!info->limit && info->charging) { in sc2731_charger_work()
348 info->charging = false; in sc2731_charger_work()
349 sc2731_charger_stop_charge(info); in sc2731_charger_work()
353 mutex_unlock(&info->lock); in sc2731_charger_work()
359 struct sc2731_charger_info *info = in sc2731_charger_usb_change() local
362 info->limit = limit; in sc2731_charger_usb_change()
364 schedule_work(&info->work); in sc2731_charger_usb_change()
369 static int sc2731_charger_hw_init(struct sc2731_charger_info *info) in sc2731_charger_hw_init() argument
376 ret = regmap_update_bits(info->regmap, SC2731_MODULE_EN1, in sc2731_charger_hw_init()
381 ret = power_supply_get_battery_info(info->psy_usb, &bat_info); in sc2731_charger_hw_init()
383 dev_warn(info->dev, "no battery information is supplied\n"); in sc2731_charger_hw_init()
412 power_supply_put_battery_info(info->psy_usb, bat_info); in sc2731_charger_hw_init()
416 ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG2, in sc2731_charger_hw_init()
422 ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, in sc2731_charger_hw_init()
433 regmap_update_bits(info->regmap, SC2731_MODULE_EN1, SC2731_CHARGE_EN, 0); in sc2731_charger_hw_init()
437 static void sc2731_charger_detect_status(struct sc2731_charger_info *info) in sc2731_charger_detect_status() argument
446 if (info->usb_phy->chg_state != USB_CHARGER_PRESENT) in sc2731_charger_detect_status()
449 usb_phy_get_charger_current(info->usb_phy, &min, &max); in sc2731_charger_detect_status()
450 info->limit = min; in sc2731_charger_detect_status()
452 schedule_work(&info->work); in sc2731_charger_detect_status()
458 struct sc2731_charger_info *info; in sc2731_charger_probe() local
462 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); in sc2731_charger_probe()
463 if (!info) in sc2731_charger_probe()
466 mutex_init(&info->lock); in sc2731_charger_probe()
467 info->dev = &pdev->dev; in sc2731_charger_probe()
468 INIT_WORK(&info->work, sc2731_charger_work); in sc2731_charger_probe()
470 info->regmap = dev_get_regmap(pdev->dev.parent, NULL); in sc2731_charger_probe()
471 if (!info->regmap) { in sc2731_charger_probe()
476 ret = of_property_read_u32(np, "reg", &info->base); in sc2731_charger_probe()
482 charger_cfg.drv_data = info; in sc2731_charger_probe()
484 info->psy_usb = devm_power_supply_register(&pdev->dev, in sc2731_charger_probe()
487 if (IS_ERR(info->psy_usb)) { in sc2731_charger_probe()
489 return PTR_ERR(info->psy_usb); in sc2731_charger_probe()
492 ret = sc2731_charger_hw_init(info); in sc2731_charger_probe()
496 info->usb_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "phys", 0); in sc2731_charger_probe()
497 if (IS_ERR(info->usb_phy)) { in sc2731_charger_probe()
499 return PTR_ERR(info->usb_phy); in sc2731_charger_probe()
502 info->usb_notify.notifier_call = sc2731_charger_usb_change; in sc2731_charger_probe()
503 ret = usb_register_notifier(info->usb_phy, &info->usb_notify); in sc2731_charger_probe()
509 sc2731_charger_detect_status(info); in sc2731_charger_probe()
516 struct sc2731_charger_info *info = platform_get_drvdata(pdev); in sc2731_charger_remove() local
518 usb_unregister_notifier(info->usb_phy, &info->usb_notify); in sc2731_charger_remove()