|
| 1 | +/* |
| 2 | + * Copyright (C) 2018 Simon Shields <simon@lineageos.org> |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: GPL-2.0+ |
| 5 | + */ |
| 6 | + |
| 7 | +enum charger_state { |
| 8 | + CHARGE_STATE_UNKNOWN = 0, |
| 9 | + CHARGE_STATE_CHARGING = 1, /* charging normally */ |
| 10 | + CHARGE_STATE_FULL = 2, /* not charging - battery full */ |
| 11 | + CHARGE_STATE_NOT_CHARGING = 3, /* not charging - some other reason */ |
| 12 | + CHARGE_STATE_DISCHARGING = 4, /* discharging */ |
| 13 | +}; |
| 14 | + |
| 15 | +struct dm_charger_ops { |
| 16 | + /** |
| 17 | + * Get the charge current of the charger. |
| 18 | + * Some devices may return the maximum charge current rather than the current charge current. |
| 19 | + * @dev - charger device. |
| 20 | + * @return -errno on error, charge current in uA. |
| 21 | + */ |
| 22 | + int (*get_current)(struct udevice *dev); |
| 23 | + /** |
| 24 | + * Set the maximum charge current for the charger. A current of zero will disable charging. |
| 25 | + * @dev - charger device |
| 26 | + * @return -errno on error, 0 otherwise. |
| 27 | + */ |
| 28 | + int (*set_current)(struct udevice *dev, unsigned int microamps); |
| 29 | + /** |
| 30 | + * Get current charging state. |
| 31 | + * @dev - charger device |
| 32 | + * @return -errno on error, enum charger_state otherwise. |
| 33 | + */ |
| 34 | + int (*get_status)(struct udevice *dev); |
| 35 | +}; |
| 36 | + |
| 37 | +int charger_get(const char *devname, struct udevice **devp); |
| 38 | +int charger_get_current(struct udevice *dev); |
| 39 | +int charger_set_current(struct udevice *dev, unsigned int microamps); |
| 40 | +int charger_get_status(struct udevice *dev); |
0 commit comments