Lines Matching +full:power +full:- +full:supplies

1 // SPDX-License-Identifier: GPL-2.0-only
44 if (!wm8350->power.rev_g_coeff) in wm8350_charge_time_min()
45 return (((min - 30) / 15) & 0xf) << 8; in wm8350_charge_time_min()
47 return (((min - 30) / 30) & 0xf) << 8; in wm8350_charge_time_min()
53 int supplies = 0; in wm8350_get_supplies() local
72 supplies = WM8350_USB_SUPPLY; in wm8350_get_supplies()
77 supplies = WM8350_USB_SUPPLY | WM8350_BATT_SUPPLY; in wm8350_get_supplies()
79 supplies = WM8350_LINE_SUPPLY; in wm8350_get_supplies()
81 supplies = WM8350_BATT_SUPPLY; in wm8350_get_supplies()
83 return supplies; in wm8350_get_supplies()
92 dev_warn(wm8350->dev, in wm8350_charger_config()
94 return -EINVAL; in wm8350_charger_config()
98 if (policy->fast_limit_USB_mA > 500) { in wm8350_charger_config()
99 dev_err(wm8350->dev, "USB fast charge > 500mA\n"); in wm8350_charger_config()
100 return -EINVAL; in wm8350_charger_config()
103 eoc_mA = WM8350_CHG_EOC_mA(policy->eoc_mA); in wm8350_charger_config()
110 reg | eoc_mA | policy->trickle_start_mV | in wm8350_charger_config()
117 WM8350_CHG_FAST_LIMIT_mA(policy->fast_limit_USB_mA); in wm8350_charger_config()
119 policy->charge_mV | policy->trickle_charge_USB_mA | in wm8350_charger_config()
121 policy->charge_timeout)); in wm8350_charger_config()
125 WM8350_CHG_FAST_LIMIT_mA(policy->fast_limit_mA); in wm8350_charger_config()
127 policy->charge_mV | policy->trickle_charge_mA | in wm8350_charger_config()
129 policy->charge_timeout)); in wm8350_charger_config()
187 struct wm8350_power *power = &wm8350->power; in wm8350_charger_handler() local
188 struct wm8350_charger_policy *policy = power->policy; in wm8350_charger_handler()
190 switch (irq - wm8350->irq_base) { in wm8350_charger_handler()
192 dev_err(wm8350->dev, "battery failed\n"); in wm8350_charger_handler()
195 dev_err(wm8350->dev, "charger timeout\n"); in wm8350_charger_handler()
196 power_supply_changed(power->battery); in wm8350_charger_handler()
203 power_supply_changed(power->battery); in wm8350_charger_handler()
207 dev_dbg(wm8350->dev, "fast charger ready\n"); in wm8350_charger_handler()
216 dev_warn(wm8350->dev, "battery < 3.9V\n"); in wm8350_charger_handler()
219 dev_warn(wm8350->dev, "battery < 3.1V\n"); in wm8350_charger_handler()
222 dev_warn(wm8350->dev, "battery < 2.85V\n"); in wm8350_charger_handler()
232 power_supply_changed(power->battery); in wm8350_charger_handler()
233 power_supply_changed(power->usb); in wm8350_charger_handler()
234 power_supply_changed(power->ac); in wm8350_charger_handler()
238 dev_err(wm8350->dev, "Unknown interrupt %d\n", irq); in wm8350_charger_handler()
245 * AC Power
251 struct wm8350 *wm8350 = dev_get_drvdata(psy->dev.parent); in wm8350_ac_get_prop()
256 val->intval = !!(wm8350_get_supplies(wm8350) & in wm8350_ac_get_prop()
260 val->intval = wm8350_read_line_uvolts(wm8350); in wm8350_ac_get_prop()
263 ret = -EINVAL; in wm8350_ac_get_prop()
275 * USB Power
281 struct wm8350 *wm8350 = dev_get_drvdata(psy->dev.parent); in wm8350_usb_get_prop()
286 val->intval = !!(wm8350_get_supplies(wm8350) & in wm8350_usb_get_prop()
290 val->intval = wm8350_read_usb_uvolts(wm8350); in wm8350_usb_get_prop()
293 ret = -EINVAL; in wm8350_usb_get_prop()
347 struct wm8350 *wm8350 = dev_get_drvdata(psy->dev.parent); in wm8350_bat_get_property()
352 val->intval = wm8350_batt_status(wm8350); in wm8350_bat_get_property()
355 val->intval = !!(wm8350_get_supplies(wm8350) & in wm8350_bat_get_property()
359 val->intval = wm8350_read_battery_uvolts(wm8350); in wm8350_bat_get_property()
362 val->intval = wm8350_bat_check_health(wm8350); in wm8350_bat_get_property()
365 val->intval = wm8350_bat_get_charge_type(wm8350); in wm8350_bat_get_property()
368 ret = -EINVAL; in wm8350_bat_get_property()
384 .name = "wm8350-ac",
392 .name = "wm8350-battery",
400 .name = "wm8350-usb",
539 struct wm8350_power *power = &wm8350->power; in wm8350_power_probe() local
540 struct wm8350_charger_policy *policy = power->policy; in wm8350_power_probe()
543 power->ac = power_supply_register(&pdev->dev, &wm8350_ac_desc, NULL); in wm8350_power_probe()
544 if (IS_ERR(power->ac)) in wm8350_power_probe()
545 return PTR_ERR(power->ac); in wm8350_power_probe()
547 power->battery = power_supply_register(&pdev->dev, &wm8350_battery_desc, in wm8350_power_probe()
549 if (IS_ERR(power->battery)) { in wm8350_power_probe()
550 ret = PTR_ERR(power->battery); in wm8350_power_probe()
554 power->usb = power_supply_register(&pdev->dev, &wm8350_usb_desc, NULL); in wm8350_power_probe()
555 if (IS_ERR(power->usb)) { in wm8350_power_probe()
556 ret = PTR_ERR(power->usb); in wm8350_power_probe()
560 ret = device_create_file(&pdev->dev, &dev_attr_charger_state); in wm8350_power_probe()
562 dev_warn(wm8350->dev, "failed to add charge sysfs: %d\n", ret); in wm8350_power_probe()
575 power_supply_unregister(power->battery); in wm8350_power_probe()
577 power_supply_unregister(power->ac); in wm8350_power_probe()
585 struct wm8350_power *power = &wm8350->power; in wm8350_power_remove() local
588 device_remove_file(&pdev->dev, &dev_attr_charger_state); in wm8350_power_remove()
589 power_supply_unregister(power->battery); in wm8350_power_remove()
590 power_supply_unregister(power->ac); in wm8350_power_remove()
591 power_supply_unregister(power->usb); in wm8350_power_remove()
599 .name = "wm8350-power",
606 MODULE_DESCRIPTION("Power supply driver for WM8350");
607 MODULE_ALIAS("platform:wm8350-power");