]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - include/linux/power/battery-charger-gauge-comm.h
power: bq2419x: configure input voltage when charger cable connected
[sojka/nv-tegra/linux-3.10.git] / include / linux / power / battery-charger-gauge-comm.h
1 /*
2  * battery-charger-gauge-comm.h -- Communication APIS between battery charger
3  *              and battery gauge driver.
4  *
5  * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
6  *
7  * Author: Laxman Dewangan <ldewangan@nvidia.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation version 2.
12  *
13  * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
14  * whether express or implied; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  * 02111-1307, USA
22  */
23
24 #ifndef _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H
25 #define _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H
26
27 #define BATTERY_SNAPSHOT_INTERVAL       2*HZ
28
29 enum battery_charger_status {
30         BATTERY_DISCHARGING,
31         BATTERY_CHARGING,
32         BATTERY_CHARGING_DONE,
33 };
34
35 struct battery_gauge_dev;
36 struct battery_charger_dev;
37
38 struct battery_gauge_ops {
39         int (*update_battery_status)(struct battery_gauge_dev *bg_device,
40                                 enum battery_charger_status status);
41         int (*set_current_broadcast) (struct battery_gauge_dev *bg_device);
42         int (*get_battery_temp)(void);
43         int (*get_battery_soc)(struct battery_gauge_dev *bg_device);
44 };
45
46 struct battery_charging_ops {
47         int (*get_charging_status)(struct battery_charger_dev *bc_dev);
48         int (*restart_charging)(struct battery_charger_dev *bc_dev);
49         int (*thermal_configure)(struct battery_charger_dev *bct_dev,
50                 int temp, bool enable_charger, bool enable_charg_half_current,
51                 int battery_voltage);
52         int (*input_voltage_configure)(struct battery_charger_dev *bc_dev,
53                 int soc);
54 };
55
56 struct battery_charger_info {
57         const char *tz_name;
58         int cell_id;
59         int polling_time_sec;
60         bool enable_thermal_monitor;
61         struct battery_charging_ops *bc_ops;
62 };
63
64 struct battery_gauge_info {
65         int cell_id;
66         const char *tz_name;
67         const char *current_channel_name;
68         struct battery_gauge_ops *bg_ops;
69 };
70
71 struct battery_charger_dev *battery_charger_register(struct device *dev,
72                 struct battery_charger_info *bci, void *drv_data);
73 void battery_charger_unregister(struct battery_charger_dev *bc_dev);
74 int battery_charging_status_update(struct battery_charger_dev *bc_dev,
75                 enum battery_charger_status status);
76 int battery_charging_restart(struct battery_charger_dev *bc_dev, int after_sec);
77 void battery_charging_restart_cancel(struct battery_charger_dev *bc_dev);
78 int battery_charger_thermal_start_monitoring(
79                 struct battery_charger_dev *bc_dev);
80 int battery_charger_thermal_stop_monitoring(
81                 struct battery_charger_dev *bc_dev);
82 int battery_charger_acquire_wake_lock(struct battery_charger_dev *bc_dev);
83 int battery_charger_release_wake_lock(struct battery_charger_dev *bc_dev);
84
85 int battery_charging_wakeup(struct battery_charger_dev *bc_dev, int after_sec);
86 int battery_charging_system_reset_after(struct battery_charger_dev *bc_dev,
87         int after_sec);
88 int battery_charging_system_power_on_usb_event(
89         struct battery_charger_dev *bc_dev);
90 int battery_gauge_get_battery_temperature(struct battery_gauge_dev *bg_dev,
91         int *temp);
92 int battery_gauge_get_battery_current(struct battery_gauge_dev *bg_dev,
93         int *current_ma);
94 int battery_charger_set_current_broadcast(struct battery_charger_dev *bc_dev);
95 struct battery_gauge_dev *battery_gauge_register(struct device *dev,
96                 struct battery_gauge_info *bgi, void *drv_data);
97 void battery_gauge_unregister(struct battery_gauge_dev *bg_dev);
98
99 void *battery_charger_get_drvdata(struct battery_charger_dev *bc_dev);
100 void battery_charger_set_drvdata(struct battery_charger_dev *bc_dev,
101                         void *data);
102 void *battery_gauge_get_drvdata(struct battery_gauge_dev *bg_dev);
103 void battery_gauge_set_drvdata(struct battery_gauge_dev *bg_dev, void *data);
104 int battery_gauge_record_voltage_value(struct battery_gauge_dev *bg_dev,
105                                                                 int voltage);
106 int battery_gauge_record_capacity_value(struct battery_gauge_dev *bg_dev,
107                                                                 int capacity);
108 int battery_gauge_record_snapshot_values(struct battery_gauge_dev *bg_dev,
109                                                                 int interval);
110 int battery_gauge_get_scaled_soc(struct battery_gauge_dev *bg_dev,
111                 int actual_soc_semi, int thresod_soc);
112 int battery_gauge_get_adjusted_soc(struct battery_gauge_dev *bg_dev,
113                 int min_soc, int max_soc, int actual_soc_semi);
114 int battery_gauge_report_battery_soc(struct battery_gauge_dev *bg_dev,
115                 int battery_soc);
116 int battery_gauge_get_battery_soc(struct battery_charger_dev *bc_dev);
117
118 #endif /* _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H */