2 * battery-charger-gauge-comm.h -- Communication APIS between battery charger
3 * and battery gauge driver.
5 * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
7 * Author: Laxman Dewangan <ldewangan@nvidia.com>
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.
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.
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
24 #ifndef _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H
25 #define _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H
27 #define BATTERY_SNAPSHOT_INTERVAL 2*HZ
29 enum battery_charger_status {
32 BATTERY_CHARGING_DONE,
35 struct battery_gauge_dev;
36 struct battery_charger_dev;
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);
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,
52 int (*input_voltage_configure)(struct battery_charger_dev *bc_dev,
56 struct battery_charger_info {
60 bool enable_thermal_monitor;
61 struct battery_charging_ops *bc_ops;
64 struct battery_gauge_info {
67 const char *current_channel_name;
68 struct battery_gauge_ops *bg_ops;
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);
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,
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,
92 int battery_gauge_get_battery_current(struct battery_gauge_dev *bg_dev,
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);
99 void *battery_charger_get_drvdata(struct battery_charger_dev *bc_dev);
100 void battery_charger_set_drvdata(struct battery_charger_dev *bc_dev,
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,
106 int battery_gauge_record_capacity_value(struct battery_gauge_dev *bg_dev,
108 int battery_gauge_record_snapshot_values(struct battery_gauge_dev *bg_dev,
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,
116 int battery_gauge_get_battery_soc(struct battery_charger_dev *bc_dev);
118 #endif /* _LINUX_POWER_BATTERY_CHARGER_GAUGE_COMM_H */