]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - include/linux/power/battery-charger-gauge-comm.h
cf0df7c4c2c843c2d1db62f2e976c3405389566e
[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 };
44
45 struct battery_charging_ops {
46         int (*get_charging_status)(struct battery_charger_dev *bc_dev);
47         int (*restart_charging)(struct battery_charger_dev *bc_dev);
48         int (*thermal_configure)(struct battery_charger_dev *bct_dev,
49                 int temp, bool enable_charger, bool enable_charg_half_current,
50                 int battery_voltage);
51         int (*input_voltage_configure)(struct battery_charger_dev *bc_dev,
52                 int soc);
53 };
54
55 struct battery_charger_info {
56         const char *tz_name;
57         int cell_id;
58         int polling_time_sec;
59         bool enable_thermal_monitor;
60         struct battery_charging_ops *bc_ops;
61 };
62
63 struct battery_gauge_info {
64         int cell_id;
65         const char *tz_name;
66         const char *current_channel_name;
67         struct battery_gauge_ops *bg_ops;
68 };
69
70 struct battery_charger_dev *battery_charger_register(struct device *dev,
71                 struct battery_charger_info *bci, void *drv_data);
72 void battery_charger_unregister(struct battery_charger_dev *bc_dev);
73 int battery_charging_status_update(struct battery_charger_dev *bc_dev,
74                 enum battery_charger_status status);
75 int battery_charging_restart(struct battery_charger_dev *bc_dev, int after_sec);
76 void battery_charging_restart_cancel(struct battery_charger_dev *bc_dev);
77 int battery_charger_thermal_start_monitoring(
78                 struct battery_charger_dev *bc_dev);
79 int battery_charger_thermal_stop_monitoring(
80                 struct battery_charger_dev *bc_dev);
81 int battery_charger_acquire_wake_lock(struct battery_charger_dev *bc_dev);
82 int battery_charger_release_wake_lock(struct battery_charger_dev *bc_dev);
83
84 int battery_charging_wakeup(struct battery_charger_dev *bc_dev, int after_sec);
85 int battery_charging_system_reset_after(struct battery_charger_dev *bc_dev,
86         int after_sec);
87 int battery_charging_system_power_on_usb_event(
88         struct battery_charger_dev *bc_dev);
89 int battery_gauge_get_battery_temperature(struct battery_gauge_dev *bg_dev,
90         int *temp);
91 int battery_gauge_get_battery_current(struct battery_gauge_dev *bg_dev,
92         int *current_ma);
93 int battery_charger_set_current_broadcast(struct battery_charger_dev *bc_dev);
94 struct battery_gauge_dev *battery_gauge_register(struct device *dev,
95                 struct battery_gauge_info *bgi, void *drv_data);
96 void battery_gauge_unregister(struct battery_gauge_dev *bg_dev);
97
98 void *battery_charger_get_drvdata(struct battery_charger_dev *bc_dev);
99 void battery_charger_set_drvdata(struct battery_charger_dev *bc_dev,
100                         void *data);
101 void *battery_gauge_get_drvdata(struct battery_gauge_dev *bg_dev);
102 void battery_gauge_set_drvdata(struct battery_gauge_dev *bg_dev, void *data);
103 int battery_gauge_record_voltage_value(struct battery_gauge_dev *bg_dev,
104                                                                 int voltage);
105 int battery_gauge_record_capacity_value(struct battery_gauge_dev *bg_dev,
106                                                                 int capacity);
107 int battery_gauge_record_snapshot_values(struct battery_gauge_dev *bg_dev,
108                                                                 int interval);
109 int battery_gauge_get_scaled_soc(struct battery_gauge_dev *bg_dev,
110                 int actual_soc_semi, int thresod_soc);
111 int battery_gauge_get_adjusted_soc(struct battery_gauge_dev *bg_dev,
112                 int min_soc, int max_soc, int actual_soc_semi);
113 int battery_gauge_report_battery_soc(struct battery_gauge_dev *bg_dev,
114                 int battery_soc);
115
116 #endif /* _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H */