Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / include / linux / power / charger-manager.h
blob4f75e531c112c176b7a29146c6581e857442dba2
1 /*
2 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
3 * MyungJoo.Ham <myungjoo.ham@samsung.com>
5 * Charger Manager.
6 * This framework enables to control and multiple chargers and to
7 * monitor charging even in the context of suspend-to-RAM with
8 * an interface combining the chargers.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 **/
15 #ifndef _CHARGER_MANAGER_H
16 #define _CHARGER_MANAGER_H
18 #include <linux/power_supply.h>
20 enum data_source {
21 CM_FUEL_GAUGE,
22 CM_CHARGER_STAT,
25 enum polling_modes {
26 CM_POLL_DISABLE = 0,
27 CM_POLL_ALWAYS,
28 CM_POLL_EXTERNAL_POWER_ONLY,
29 CM_POLL_CHARGING_ONLY,
32 /**
33 * struct charger_global_desc
34 * @rtc_name: the name of RTC used to wake up the system from suspend.
35 * @rtc_only_wakeup:
36 * If the system is woken up by waekup-sources other than the RTC or
37 * callbacks, Charger Manager should recognize with
38 * rtc_only_wakeup() returning false.
39 * If the RTC given to CM is the only wakeup reason,
40 * rtc_only_wakeup should return true.
42 struct charger_global_desc {
43 char *rtc_name;
45 bool (*rtc_only_wakeup)(void);
48 /**
49 * struct charger_desc
50 * @psy_name: the name of power-supply-class for charger manager
51 * @polling_mode:
52 * Determine which polling mode will be used
53 * @fullbatt_uV: voltage in microvolt
54 * If it is not being charged and VBATT >= fullbatt_uV,
55 * it is assumed to be full.
56 * @polling_interval_ms: interval in millisecond at which
57 * charger manager will monitor battery health
58 * @battery_present:
59 * Specify where information for existance of battery can be obtained
60 * @psy_charger_stat: the names of power-supply for chargers
61 * @num_charger_regulator: the number of entries in charger_regulators
62 * @charger_regulators: array of regulator_bulk_data for chargers
63 * @psy_fuel_gauge: the name of power-supply for fuel gauge
64 * @temperature_out_of_range:
65 * Determine whether the status is overheat or cold or normal.
66 * return_value > 0: overheat
67 * return_value == 0: normal
68 * return_value < 0: cold
69 * @measure_battery_temp:
70 * true: measure battery temperature
71 * false: measure ambient temperature
73 struct charger_desc {
74 char *psy_name;
76 enum polling_modes polling_mode;
77 unsigned int polling_interval_ms;
79 unsigned int fullbatt_uV;
81 enum data_source battery_present;
83 char **psy_charger_stat;
85 int num_charger_regulators;
86 struct regulator_bulk_data *charger_regulators;
88 char *psy_fuel_gauge;
90 int (*temperature_out_of_range)(int *mC);
91 bool measure_battery_temp;
94 #define PSY_NAME_MAX 30
96 /**
97 * struct charger_manager
98 * @entry: entry for list
99 * @dev: device pointer
100 * @desc: instance of charger_desc
101 * @fuel_gauge: power_supply for fuel gauge
102 * @charger_stat: array of power_supply for chargers
103 * @charger_enabled: the state of charger
104 * @emergency_stop:
105 * When setting true, stop charging
106 * @last_temp_mC: the measured temperature in milli-Celsius
107 * @psy_name_buf: the name of power-supply-class for charger manager
108 * @charger_psy: power_supply for charger manager
109 * @status_save_ext_pwr_inserted:
110 * saved status of external power before entering suspend-to-RAM
111 * @status_save_batt:
112 * saved status of battery before entering suspend-to-RAM
114 struct charger_manager {
115 struct list_head entry;
116 struct device *dev;
117 struct charger_desc *desc;
119 struct power_supply *fuel_gauge;
120 struct power_supply **charger_stat;
122 bool charger_enabled;
124 int emergency_stop;
125 int last_temp_mC;
127 char psy_name_buf[PSY_NAME_MAX + 1];
128 struct power_supply charger_psy;
130 bool status_save_ext_pwr_inserted;
131 bool status_save_batt;
134 #ifdef CONFIG_CHARGER_MANAGER
135 extern int setup_charger_manager(struct charger_global_desc *gd);
136 extern bool cm_suspend_again(void);
137 #else
138 static void __maybe_unused setup_charger_manager(struct charger_global_desc *gd)
141 static bool __maybe_unused cm_suspend_again(void)
143 return false;
145 #endif
147 #endif /* _CHARGER_MANAGER_H */