Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
linux
power
charger-manager.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2011 Samsung Electronics Co., Ltd.
3
* MyungJoo.Ham <
[email protected]
>
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
#include <
linux/extcon.h
>
20
21
enum
data_source
{
22
CM_BATTERY_PRESENT
,
23
CM_NO_BATTERY
,
24
CM_FUEL_GAUGE
,
25
CM_CHARGER_STAT
,
26
};
27
28
enum
polling_modes
{
29
CM_POLL_DISABLE
= 0,
30
CM_POLL_ALWAYS
,
31
CM_POLL_EXTERNAL_POWER_ONLY
,
32
CM_POLL_CHARGING_ONLY
,
33
};
34
35
enum
cm_event_types
{
36
CM_EVENT_UNKNOWN
= 0,
37
CM_EVENT_BATT_FULL
,
38
CM_EVENT_BATT_IN
,
39
CM_EVENT_BATT_OUT
,
40
CM_EVENT_EXT_PWR_IN_OUT
,
41
CM_EVENT_CHG_START_STOP
,
42
CM_EVENT_OTHERS
,
43
};
44
60
struct
charger_global_desc
{
61
char
*
rtc_name
;
62
63
bool
(*
rtc_only_wakeup
)(
void
);
64
65
bool
assume_timer_stops_in_suspend
;
66
};
67
84
struct
charger_cable
{
85
const
char
*
extcon_name
;
86
const
char
*
name
;
87
88
/* The charger-manager use Exton framework*/
89
struct
extcon_specific_cable_nb
extcon_dev
;
90
struct
work_struct
wq
;
91
struct
notifier_block
nb
;
92
93
/* The state of charger cable */
94
bool
attached
;
95
96
struct
charger_regulator
*
charger
;
97
98
/*
99
* Set min/max current of regulator to protect over-current issue
100
* according to a kind of charger cable when cable is attached.
101
*/
102
int
min_uA
;
103
int
max_uA
;
104
105
struct
charger_manager
*
cm
;
106
};
107
127
struct
charger_regulator
{
128
/* The name of regulator for charging */
129
const
char
*
regulator_name
;
130
struct
regulator
*
consumer
;
131
132
/* charger never on when system is on */
133
int
externally_control
;
134
135
/*
136
* Store constraint information related to current limit,
137
* each cable have different condition for charging.
138
*/
139
struct
charger_cable
*
cables
;
140
int
num_cables
;
141
142
struct
attribute_group
attr_g
;
143
struct
device_attribute
attr_name
;
144
struct
device_attribute
attr_state
;
145
struct
device_attribute
attr_externally_control
;
146
struct
attribute
*
attrs
[4];
147
148
struct
charger_manager
*
cm
;
149
};
150
192
struct
charger_desc
{
193
char
*
psy_name
;
194
195
enum
polling_modes
polling_mode
;
196
unsigned
int
polling_interval_ms
;
197
198
unsigned
int
fullbatt_vchkdrop_ms
;
199
unsigned
int
fullbatt_vchkdrop_uV
;
200
unsigned
int
fullbatt_uV
;
201
unsigned
int
fullbatt_soc
;
202
unsigned
int
fullbatt_full_capacity
;
203
204
enum
data_source
battery_present
;
205
206
char
**
psy_charger_stat
;
207
208
int
num_charger_regulators
;
209
struct
charger_regulator
*
charger_regulators
;
210
211
char
*
psy_fuel_gauge
;
212
213
int
(*
temperature_out_of_range
)(
int
*mC);
214
bool
measure_battery_temp
;
215
216
u64
charging_max_duration_ms
;
217
u64
discharging_max_duration_ms
;
218
};
219
220
#define PSY_NAME_MAX 30
221
245
struct
charger_manager
{
246
struct
list_head
entry
;
247
struct
device
*
dev
;
248
struct
charger_desc
*
desc
;
249
250
struct
power_supply
*
fuel_gauge
;
251
struct
power_supply
**
charger_stat
;
252
253
bool
charger_enabled
;
254
255
unsigned
long
fullbatt_vchk_jiffies_at
;
256
struct
delayed_work
fullbatt_vchk_work
;
257
258
int
emergency_stop
;
259
int
last_temp_mC
;
260
261
char
psy_name_buf
[
PSY_NAME_MAX
+ 1];
262
struct
power_supply
charger_psy
;
263
264
bool
status_save_ext_pwr_inserted
;
265
bool
status_save_batt
;
266
267
u64
charging_start_time
;
268
u64
charging_end_time
;
269
};
270
271
#ifdef CONFIG_CHARGER_MANAGER
272
extern
int
setup_charger_manager
(
struct
charger_global_desc
*gd);
273
extern
bool
cm_suspend_again
(
void
);
274
extern
void
cm_notify_event
(
struct
power_supply
*psy,
275
enum
cm_event_types
type
,
char
*
msg
);
276
#else
277
static
inline
int
setup_charger_manager
(
struct
charger_global_desc
*gd)
278
{
return
0; }
279
static
inline
bool
cm_suspend_again
(
void
) {
return
false
; }
280
static
inline
void
cm_notify_event
(
struct
power_supply
*psy,
281
enum
cm_event_types
type
,
char
*
msg
) { }
282
#endif
283
#endif
/* _CHARGER_MANAGER_H */
Generated on Thu Jan 10 2013 14:52:24 for Linux Kernel by
1.8.2