blob: 3b84f37ed9569b8e6999b8b1cbd10acaf8e36a02 [file] [log] [blame]
Kiran Gunda1bc78922017-09-19 13:09:44 +05301/*
2 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#ifndef __MSM_BCL_H
15#define __MSM_BCL_H
16
17#define BCL_NAME_MAX_LEN 20
18
19enum bcl_trip_type {
20 BCL_HIGH_TRIP,
21 BCL_LOW_TRIP,
22 BCL_TRIP_MAX,
23};
24
25enum bcl_param {
26 BCL_PARAM_VOLTAGE,
27 BCL_PARAM_CURRENT,
28 BCL_PARAM_MAX,
29};
30
31struct bcl_threshold {
32 int trip_value;
33 enum bcl_trip_type type;
34 void *trip_data;
35 void (*trip_notify) (enum bcl_trip_type, int, void *);
36};
37struct bcl_param_data;
38struct bcl_driver_ops {
39 int (*read) (int *);
40 int (*set_high_trip) (int);
41 int (*get_high_trip) (int *);
42 int (*set_low_trip) (int);
43 int (*get_low_trip) (int *);
44 int (*disable) (void);
45 int (*enable) (void);
46 int (*notify) (struct bcl_param_data *, int,
47 enum bcl_trip_type);
48};
49
50struct bcl_param_data {
51 char name[BCL_NAME_MAX_LEN];
52 struct device device;
53 struct bcl_driver_ops *ops;
54 int high_trip;
55 int low_trip;
56 int last_read_val;
57 bool registered;
58 struct kobj_attribute val_attr;
59 struct kobj_attribute high_trip_attr;
60 struct kobj_attribute low_trip_attr;
61 struct attribute_group bcl_attr_gp;
62 struct bcl_threshold *thresh[BCL_TRIP_MAX];
63};
64
65#ifdef CONFIG_MSM_BCL_CTL
66struct bcl_param_data *msm_bcl_register_param(enum bcl_param,
67 struct bcl_driver_ops *, char *);
68int msm_bcl_unregister_param(struct bcl_param_data *);
69int msm_bcl_enable(void);
70int msm_bcl_disable(void);
71int msm_bcl_set_threshold(enum bcl_param, enum bcl_trip_type,
72 struct bcl_threshold *);
73int msm_bcl_read(enum bcl_param, int *);
74#else
75static inline struct bcl_param_data *msm_bcl_register_param(
76 enum bcl_param param_type, struct bcl_driver_ops *ops, char *name)
77{
78 return NULL;
79}
80static inline int msm_bcl_unregister_param(struct bcl_param_data *data)
81{
82 return -ENOSYS;
83}
84static inline int msm_bcl_enable(void)
85{
86 return -ENOSYS;
87}
88static inline int msm_bcl_disable(void)
89{
90 return -ENOSYS;
91}
92static inline int msm_bcl_set_threshold(enum bcl_param param_type,
93 enum bcl_trip_type type,
94 struct bcl_threshold *inp_thresh)
95{
96 return -ENOSYS;
97}
98static inline int msm_bcl_read(enum bcl_param param_type, int *vbat_value)
99{
100 return -ENOSYS;
101}
102#endif
103
104#endif /*__MSM_BCL_H*/