diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2012-11-02 15:18:11 -0400 |
---|---|---|
committer | Anton Vorontsov <cbouatmailru@gmail.com> | 2012-11-18 18:39:04 -0500 |
commit | 0bc98cc6155205b615a9d29a2d54d1b839521c04 (patch) | |
tree | 285b6f17d4f050203aa0b14a0cffe63b43970569 /include/linux/power | |
parent | 04930baf28f08cd275e4afbf5a335b42335705df (diff) |
power_supply: Add bq2415x charger driver
The bq2415x charger driver is needed for example on Nokia N900 for
charging battery. Driver is part of open source project to replace
proprietary battery management.
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'include/linux/power')
-rw-r--r-- | include/linux/power/bq2415x_charger.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/include/linux/power/bq2415x_charger.h b/include/linux/power/bq2415x_charger.h new file mode 100644 index 000000000000..fb6bf4d8aea8 --- /dev/null +++ b/include/linux/power/bq2415x_charger.h | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | bq2415x_charger.h - bq2415x charger driver | ||
3 | Copyright (C) 2011-2012 Pali Rohár <pali.rohar@gmail.com> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along | ||
16 | with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef BQ2415X_CHARGER_H | ||
21 | #define BQ2415X_CHARGER_H | ||
22 | |||
23 | /* | ||
24 | This is platform data for bq2415x chip. It contains default board voltages | ||
25 | and currents which can be also later configured via sysfs. If value is -1 | ||
26 | then default chip value (specified in datasheet) will be used. | ||
27 | |||
28 | Value resistor_sense is needed for for configuring charge and termination | ||
29 | current. It it is less or equal to zero, configuring charge and termination | ||
30 | current will not be possible. | ||
31 | |||
32 | Function set_mode_hook is needed for automode (setting correct current limit | ||
33 | when charger is connected/disconnected or setting boost mode). When is NULL, | ||
34 | automode function is disabled. When is not NULL, it must have this prototype: | ||
35 | |||
36 | int (*set_mode_hook)( | ||
37 | void (*hook)(enum bq2415x_mode mode, void *data), | ||
38 | void *data) | ||
39 | |||
40 | hook is hook function (see below) and data is pointer to driver private data | ||
41 | |||
42 | bq2415x driver will call it as: | ||
43 | |||
44 | platform_data->set_mode_hook(bq2415x_hook_function, bq2415x_device); | ||
45 | |||
46 | Board/platform function set_mode_hook return non zero value when hook | ||
47 | function was successful registered. Platform code should call that hook | ||
48 | function (which get from pointer, with data) every time when charger was | ||
49 | connected/disconnected or require to enable boost mode. bq2415x driver then | ||
50 | will set correct current limit, enable/disable charger or boost mode. | ||
51 | |||
52 | Hook function has this prototype: | ||
53 | |||
54 | void hook(enum bq2415x_mode mode, void *data); | ||
55 | |||
56 | mode is bq2415x mode (charger or boost) | ||
57 | data is pointer to driver private data (which get from set_charger_type_hook) | ||
58 | |||
59 | When bq driver is being unloaded, it call function: | ||
60 | |||
61 | platform_data->set_mode_hook(NULL, NULL); | ||
62 | |||
63 | (hook function and driver private data are NULL) | ||
64 | |||
65 | After that board/platform code must not call driver hook function! It is | ||
66 | possible that pointer to hook function will not be valid and calling will | ||
67 | cause undefined result. | ||
68 | |||
69 | */ | ||
70 | |||
71 | /* Supported modes with maximal current limit */ | ||
72 | enum bq2415x_mode { | ||
73 | BQ2415X_MODE_NONE, /* unknown or no charger (100mA) */ | ||
74 | BQ2415X_MODE_HOST_CHARGER, /* usb host/hub charger (500mA) */ | ||
75 | BQ2415X_MODE_DEDICATED_CHARGER, /* dedicated charger (unlimited) */ | ||
76 | BQ2415X_MODE_BOOST, /* boost mode (charging disabled) */ | ||
77 | }; | ||
78 | |||
79 | struct bq2415x_platform_data { | ||
80 | int current_limit; /* mA */ | ||
81 | int weak_battery_voltage; /* mV */ | ||
82 | int battery_regulation_voltage; /* mV */ | ||
83 | int charge_current; /* mA */ | ||
84 | int termination_current; /* mA */ | ||
85 | int resistor_sense; /* m ohm */ | ||
86 | int (*set_mode_hook)(void (*hook)(enum bq2415x_mode mode, void *data), | ||
87 | void *data); | ||
88 | }; | ||
89 | |||
90 | #endif | ||