OSDN Git Service

devfreq_boost: Introduce devfreq boost driver
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / of_batterydata.h
1 /* Copyright (c) 2013-2014, 2016 The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12
13 #include <linux/of.h>
14 #include <linux/batterydata-lib.h>
15
16 #ifdef CONFIG_OF_BATTERYDATA
17 /**
18  * of_batterydata_read_data() - Populate battery data from the device tree
19  * @container_node: pointer to the battery-data container device node
20  *              containing the profile nodes.
21  * @batt_data: pointer to an allocated bms_battery_data structure that the
22  *              loaded profile will be written to.
23  * @batt_id_uv: ADC voltage of the battery id line used to differentiate
24  *              between different battery profiles. If there are multiple
25  *              battery data in the device tree, the one with the closest
26  *              battery id resistance will be automatically loaded.
27  *
28  * This routine loads the closest match battery data from device tree based on
29  * the battery id reading. Then, it will try to load all the relevant data from
30  * the device tree battery data profile.
31  *
32  * If any of the lookup table pointers are NULL, this routine will skip trying
33  * to read them.
34  */
35 int of_batterydata_read_data(struct device_node *container_node,
36                                 struct bms_battery_data *batt_data,
37                                 int batt_id_uv);
38 /**
39  * of_batterydata_get_best_profile() - Find matching battery data device node
40  * @batterydata_container_node: pointer to the battery-data container device
41  *              node containing the profile nodes.
42  * @batt_id_kohm: Battery ID in KOhms for which we want to find the profile.
43  * @batt_type: Battery type which we want to force load the profile.
44  *
45  * This routine returns a device_node pointer to the closest match battery data
46  * from device tree based on the battery id reading.
47  */
48 struct device_node *of_batterydata_get_best_profile(
49                 struct device_node *batterydata_container_node,
50                 int batt_id_kohm, const char *batt_type);
51 #else
52 static inline int of_batterydata_read_data(struct device_node *container_node,
53                                 struct bms_battery_data *batt_data,
54                                 int batt_id_uv)
55 {
56         return -ENXIO;
57 }
58 static inline struct device_node *of_batterydata_get_best_profile(
59                 struct device_node *batterydata_container_node,
60                 int batt_id_kohm, const char *batt_type)
61 {
62         return -ENXIO;
63 }
64 #endif /* CONFIG_OF_QPNP */