aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/power
diff options
context:
space:
mode:
authorDonggeun Kim <dg77.kim@samsung.com>2011-12-27 04:47:48 -0500
committerAnton Vorontsov <cbouatmailru@gmail.com>2012-01-03 23:08:27 -0500
commit3bb3dbbd56ea39e5537db8f8041ea95d28f16a7f (patch)
treeb660ceed66ef404530109f9670b63640bd2be4b6 /include/linux/power
parent00a159a5567232fbe1dd85bc611c55f53943b0fc (diff)
power_supply: Add initial Charger-Manager driver
Because battery health monitoring should be done even when suspended, it needs to wake up and suspend periodically. Thus, userspace battery monitoring may incur too much overhead; every device and task is woken up periodically. Charger Manager uses suspend-again to provide in-suspend monitoring. This patch allows to monitor battery health in-suspend state. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'include/linux/power')
-rw-r--r--include/linux/power/charger-manager.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
new file mode 100644
index 000000000000..102c5b3f3325
--- /dev/null
+++ b/include/linux/power/charger-manager.h
@@ -0,0 +1,130 @@
1/*
2 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
3 * MyungJoo.Ham <myungjoo.ham@samsung.com>
4 *
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.
9 *
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**/
14
15#ifndef _CHARGER_MANAGER_H
16#define _CHARGER_MANAGER_H
17
18#include <linux/power_supply.h>
19
20enum data_source {
21 CM_FUEL_GAUGE,
22 CM_CHARGER_STAT,
23};
24
25enum polling_modes {
26 CM_POLL_DISABLE = 0,
27 CM_POLL_ALWAYS,
28 CM_POLL_EXTERNAL_POWER_ONLY,
29 CM_POLL_CHARGING_ONLY,
30};
31
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.
41 */
42struct charger_global_desc {
43 char *rtc_name;
44
45 bool (*rtc_only_wakeup)(void);
46};
47
48/**
49 * struct charger_desc
50 * @polling_mode:
51 * Determine which polling mode will be used
52 * @polling_interval_ms: interval in millisecond at which
53 * charger manager will monitor battery health
54 * @battery_present:
55 * Specify where information for existance of battery can be obtained
56 * @psy_charger_stat: the names of power-supply for chargers
57 * @num_charger_regulator: the number of entries in charger_regulators
58 * @charger_regulators: array of regulator_bulk_data for chargers
59 * @psy_fuel_gauge: the name of power-supply for fuel gauge
60 * @temperature_out_of_range:
61 * Determine whether the status is overheat or cold or normal.
62 * return_value > 0: overheat
63 * return_value == 0: normal
64 * return_value < 0: cold
65 */
66struct charger_desc {
67 enum polling_modes polling_mode;
68 unsigned int polling_interval_ms;
69
70 enum data_source battery_present;
71
72 char **psy_charger_stat;
73
74 int num_charger_regulators;
75 struct regulator_bulk_data *charger_regulators;
76
77 char *psy_fuel_gauge;
78
79 int (*temperature_out_of_range)(int *mC);
80};
81
82#define PSY_NAME_MAX 30
83
84/**
85 * struct charger_manager
86 * @entry: entry for list
87 * @dev: device pointer
88 * @desc: instance of charger_desc
89 * @fuel_gauge: power_supply for fuel gauge
90 * @charger_stat: array of power_supply for chargers
91 * @charger_enabled: the state of charger
92 * @emergency_stop:
93 * When setting true, stop charging
94 * @last_temp_mC: the measured temperature in milli-Celsius
95 * @status_save_ext_pwr_inserted:
96 * saved status of external power before entering suspend-to-RAM
97 * @status_save_batt:
98 * saved status of battery before entering suspend-to-RAM
99 */
100struct charger_manager {
101 struct list_head entry;
102 struct device *dev;
103 struct charger_desc *desc;
104
105 struct power_supply *fuel_gauge;
106 struct power_supply **charger_stat;
107
108 bool charger_enabled;
109
110 int emergency_stop;
111 int last_temp_mC;
112
113 bool status_save_ext_pwr_inserted;
114 bool status_save_batt;
115};
116
117#ifdef CONFIG_CHARGER_MANAGER
118extern int setup_charger_manager(struct charger_global_desc *gd);
119extern bool cm_suspend_again(void);
120#else
121static void __maybe_unused setup_charger_manager(struct charger_global_desc *gd)
122{ }
123
124static bool __maybe_unused cm_suspend_again(void)
125{
126 return false;
127}
128#endif
129
130#endif /* _CHARGER_MANAGER_H */