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