xref: /openbmc/linux/drivers/power/supply/ab8500-chargalg.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1a65aa0ceSLinus Walleij /* SPDX-License-Identifier: GPL-2.0-only */
2a65aa0ceSLinus Walleij /*
3a65aa0ceSLinus Walleij  * Copyright (C) ST-Ericsson SA 2012
4a65aa0ceSLinus Walleij  * Author: Johan Gardsmark <johan.gardsmark@stericsson.com> for ST-Ericsson.
5a65aa0ceSLinus Walleij  */
6a65aa0ceSLinus Walleij 
7a65aa0ceSLinus Walleij #ifndef _AB8500_CHARGALG_H_
8a65aa0ceSLinus Walleij #define _AB8500_CHARGALG_H_
9a65aa0ceSLinus Walleij 
10a65aa0ceSLinus Walleij #include <linux/power_supply.h>
11a65aa0ceSLinus Walleij 
12a65aa0ceSLinus Walleij /*
13a65aa0ceSLinus Walleij  * Valid only for supplies of type:
14a65aa0ceSLinus Walleij  * - POWER_SUPPLY_TYPE_MAINS,
15a65aa0ceSLinus Walleij  * - POWER_SUPPLY_TYPE_USB,
16a65aa0ceSLinus Walleij  * because only them store as drv_data pointer to struct ux500_charger.
17a65aa0ceSLinus Walleij  */
18f1c74a6cSLinus Walleij #define psy_to_ux500_charger(x) power_supply_get_drvdata(x)
19a65aa0ceSLinus Walleij 
20a65aa0ceSLinus Walleij /* Forward declaration */
21a65aa0ceSLinus Walleij struct ux500_charger;
22a65aa0ceSLinus Walleij 
23a65aa0ceSLinus Walleij struct ux500_charger_ops {
24a65aa0ceSLinus Walleij 	int (*enable) (struct ux500_charger *, int, int, int);
25a65aa0ceSLinus Walleij 	int (*check_enable) (struct ux500_charger *, int, int);
26a65aa0ceSLinus Walleij 	int (*kick_wd) (struct ux500_charger *);
27a65aa0ceSLinus Walleij 	int (*update_curr) (struct ux500_charger *, int);
28a65aa0ceSLinus Walleij };
29a65aa0ceSLinus Walleij 
30a65aa0ceSLinus Walleij /**
31a65aa0ceSLinus Walleij  * struct ux500_charger - power supply ux500 charger sub class
32a65aa0ceSLinus Walleij  * @psy			power supply base class
33a65aa0ceSLinus Walleij  * @ops			ux500 charger operations
34*bc6e0287SLinus Walleij  * @max_out_volt_uv	maximum output charger voltage in uV
3583e5aa77SLinus Walleij  * @max_out_curr_ua	maximum output charger current in uA
36a65aa0ceSLinus Walleij  * @enabled		indicates if this charger is used or not
37a65aa0ceSLinus Walleij  */
38a65aa0ceSLinus Walleij struct ux500_charger {
39a65aa0ceSLinus Walleij 	struct power_supply *psy;
40a65aa0ceSLinus Walleij 	struct ux500_charger_ops ops;
41*bc6e0287SLinus Walleij 	int max_out_volt_uv;
4283e5aa77SLinus Walleij 	int max_out_curr_ua;
43a65aa0ceSLinus Walleij 	int wdt_refresh;
44a65aa0ceSLinus Walleij 	bool enabled;
45a65aa0ceSLinus Walleij };
46a65aa0ceSLinus Walleij 
47a65aa0ceSLinus Walleij #endif /* _AB8500_CHARGALG_H_ */
48