Lines Matching +full:sysvdd +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
36 static int wm831x_power_check_online(struct wm831x *wm831x, int supply, in wm831x_power_check_online() argument
45 if (ret & supply) in wm831x_power_check_online()
46 val->intval = 1; in wm831x_power_check_online()
48 val->intval = 0; in wm831x_power_check_online()
61 val->intval = ret; in wm831x_power_read_voltage()
73 struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev.parent); in wm831x_wall_get_prop()
74 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_wall_get_prop()
85 ret = -EINVAL; in wm831x_wall_get_prop()
104 struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev.parent); in wm831x_usb_get_prop()
105 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_usb_get_prop()
116 ret = -EINVAL; in wm831x_usb_get_prop()
156 dev_dbg(wm831x_power->wm831x->dev, in wm831x_usb_limit_change()
159 wm831x_set_bits(wm831x_power->wm831x, WM831X_POWER_STATE, in wm831x_usb_limit_change()
248 dev_err(wm831x->dev, "Invalid %s %d%s\n", in wm831x_battery_apply_config()
252 dev_dbg(wm831x->dev, "Set %s of %d%s\n", name, val, units); in wm831x_battery_apply_config()
258 struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data; in wm831x_config_battery()
262 if (!wm831x_pdata || !wm831x_pdata->battery) { in wm831x_config_battery()
263 dev_warn(wm831x->dev, in wm831x_config_battery()
268 pdata = wm831x_pdata->battery; in wm831x_config_battery()
273 if (!pdata->enable) { in wm831x_config_battery()
274 dev_info(wm831x->dev, "Battery charger disabled\n"); in wm831x_config_battery()
279 if (pdata->off_mask) in wm831x_config_battery()
281 if (pdata->fast_enable) in wm831x_config_battery()
286 pdata->trickle_ilim, ®2, in wm831x_config_battery()
290 pdata->vsel, ®2, in wm831x_config_battery()
294 pdata->fast_ilim, ®2, in wm831x_config_battery()
298 pdata->eoc_iterm, ®1, in wm831x_config_battery()
302 pdata->timeout, ®2, in wm831x_config_battery()
307 dev_err(wm831x->dev, "Failed to unlock registers: %d\n", ret); in wm831x_config_battery()
317 dev_err(wm831x->dev, "Failed to set charger control 1: %d\n", in wm831x_config_battery()
328 dev_err(wm831x->dev, "Failed to set charger control 2: %d\n", in wm831x_config_battery()
436 struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev.parent); in wm831x_bat_get_prop()
437 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_bat_get_prop()
442 ret = wm831x_bat_check_status(wm831x, &val->intval); in wm831x_bat_get_prop()
452 ret = wm831x_bat_check_health(wm831x, &val->intval); in wm831x_bat_get_prop()
455 ret = wm831x_bat_check_type(wm831x, &val->intval); in wm831x_bat_get_prop()
458 ret = -EINVAL; in wm831x_bat_get_prop()
487 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_bat_irq()
489 dev_dbg(wm831x->dev, "Battery status changed: %d\n", irq); in wm831x_bat_irq()
493 if (wm831x_power->have_battery) in wm831x_bat_irq()
494 power_supply_changed(wm831x_power->battery); in wm831x_bat_irq()
507 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_syslo_irq()
511 dev_crit(wm831x->dev, "SYSVDD under voltage\n"); in wm831x_syslo_irq()
519 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_pwr_src_irq()
521 dev_dbg(wm831x->dev, "Power source changed\n"); in wm831x_pwr_src_irq()
523 /* Just notify for everything - little harm in overnotifying. */ in wm831x_pwr_src_irq()
524 if (wm831x_power->have_battery) in wm831x_pwr_src_irq()
525 power_supply_changed(wm831x_power->battery); in wm831x_pwr_src_irq()
526 power_supply_changed(wm831x_power->usb); in wm831x_pwr_src_irq()
527 power_supply_changed(wm831x_power->wall); in wm831x_pwr_src_irq()
534 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); in wm831x_power_probe()
535 struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data; in wm831x_power_probe()
539 power = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_power), in wm831x_power_probe()
542 return -ENOMEM; in wm831x_power_probe()
544 power->wm831x = wm831x; in wm831x_power_probe()
547 if (wm831x_pdata && wm831x_pdata->wm831x_num) { in wm831x_power_probe()
548 snprintf(power->wall_name, sizeof(power->wall_name), in wm831x_power_probe()
549 "wm831x-wall.%d", wm831x_pdata->wm831x_num); in wm831x_power_probe()
550 snprintf(power->battery_name, sizeof(power->wall_name), in wm831x_power_probe()
551 "wm831x-battery.%d", wm831x_pdata->wm831x_num); in wm831x_power_probe()
552 snprintf(power->usb_name, sizeof(power->wall_name), in wm831x_power_probe()
553 "wm831x-usb.%d", wm831x_pdata->wm831x_num); in wm831x_power_probe()
555 snprintf(power->wall_name, sizeof(power->wall_name), in wm831x_power_probe()
556 "wm831x-wall"); in wm831x_power_probe()
557 snprintf(power->battery_name, sizeof(power->wall_name), in wm831x_power_probe()
558 "wm831x-battery"); in wm831x_power_probe()
559 snprintf(power->usb_name, sizeof(power->wall_name), in wm831x_power_probe()
560 "wm831x-usb"); in wm831x_power_probe()
568 power->wall_desc.name = power->wall_name; in wm831x_power_probe()
569 power->wall_desc.type = POWER_SUPPLY_TYPE_MAINS; in wm831x_power_probe()
570 power->wall_desc.properties = wm831x_wall_props; in wm831x_power_probe()
571 power->wall_desc.num_properties = ARRAY_SIZE(wm831x_wall_props); in wm831x_power_probe()
572 power->wall_desc.get_property = wm831x_wall_get_prop; in wm831x_power_probe()
573 power->wall = devm_power_supply_register(&pdev->dev, in wm831x_power_probe()
574 &power->wall_desc, in wm831x_power_probe()
576 if (IS_ERR(power->wall)) { in wm831x_power_probe()
577 ret = PTR_ERR(power->wall); in wm831x_power_probe()
581 power->usb_desc.name = power->usb_name, in wm831x_power_probe()
582 power->usb_desc.type = POWER_SUPPLY_TYPE_USB; in wm831x_power_probe()
583 power->usb_desc.properties = wm831x_usb_props; in wm831x_power_probe()
584 power->usb_desc.num_properties = ARRAY_SIZE(wm831x_usb_props); in wm831x_power_probe()
585 power->usb_desc.get_property = wm831x_usb_get_prop; in wm831x_power_probe()
586 power->usb = devm_power_supply_register(&pdev->dev, in wm831x_power_probe()
587 &power->usb_desc, in wm831x_power_probe()
589 if (IS_ERR(power->usb)) { in wm831x_power_probe()
590 ret = PTR_ERR(power->usb); in wm831x_power_probe()
597 power->have_battery = ret & WM831X_CHG_ENA; in wm831x_power_probe()
599 if (power->have_battery) { in wm831x_power_probe()
600 power->battery_desc.name = power->battery_name; in wm831x_power_probe()
601 power->battery_desc.properties = wm831x_bat_props; in wm831x_power_probe()
602 power->battery_desc.num_properties = ARRAY_SIZE(wm831x_bat_props); in wm831x_power_probe()
603 power->battery_desc.get_property = wm831x_bat_get_prop; in wm831x_power_probe()
604 power->battery_desc.use_for_apm = 1; in wm831x_power_probe()
605 power->battery = devm_power_supply_register(&pdev->dev, in wm831x_power_probe()
606 &power->battery_desc, in wm831x_power_probe()
608 if (IS_ERR(power->battery)) { in wm831x_power_probe()
609 ret = PTR_ERR(power->battery); in wm831x_power_probe()
619 dev_err(&pdev->dev, "Failed to request SYSLO IRQ %d: %d\n", in wm831x_power_probe()
629 dev_err(&pdev->dev, "Failed to request PWR SRC IRQ %d: %d\n", in wm831x_power_probe()
643 dev_err(&pdev->dev, in wm831x_power_probe()
650 power->usb_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "phys", 0); in wm831x_power_probe()
651 ret = PTR_ERR_OR_ZERO(power->usb_phy); in wm831x_power_probe()
655 power->usb_notify.notifier_call = wm831x_usb_limit_change; in wm831x_power_probe()
656 ret = usb_register_notifier(power->usb_phy, &power->usb_notify); in wm831x_power_probe()
658 dev_err(&pdev->dev, "Failed to register notifier: %d\n", in wm831x_power_probe()
663 case -EINVAL: in wm831x_power_probe()
664 case -ENODEV: in wm831x_power_probe()
665 /* ignore missing usb-phy, it's optional */ in wm831x_power_probe()
666 power->usb_phy = NULL; in wm831x_power_probe()
670 dev_err(&pdev->dev, "Failed to find USB phy: %d\n", ret); in wm831x_power_probe()
672 case -EPROBE_DEFER: in wm831x_power_probe()
679 --i; in wm831x_power_probe()
680 for (; i >= 0; i--) { in wm831x_power_probe()
699 struct wm831x *wm831x = wm831x_power->wm831x; in wm831x_power_remove()
702 if (wm831x_power->usb_phy) { in wm831x_power_remove()
703 usb_unregister_notifier(wm831x_power->usb_phy, in wm831x_power_remove()
704 &wm831x_power->usb_notify); in wm831x_power_remove()
725 .name = "wm831x-power",
731 MODULE_DESCRIPTION("Power supply driver for WM831x PMICs");
734 MODULE_ALIAS("platform:wm831x-power");