tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / linux / battery / sec_charger.h
1 /*
2  * sec_charger.h
3  * Samsung Mobile Charger Header
4  *
5  * Copyright (C) 2012 Samsung Electronics, Inc.
6  *
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  */
18
19 #ifndef __SEC_CHARGER_H
20 #define __SEC_CHARGER_H __FILE__
21
22 #if defined(CONFIG_CHARGER_MFD) || \
23         defined(CONFIG_CHARGER_SPRD4SAMSUNG27X3) && \
24         !defined(CONFIG_CHARGER_SM5414) && \
25         !defined(CONFIG_CHARGER_SMB328)
26 #define charger_variable charger
27 #define charger_variable_t struct sec_charger_info
28 #else
29 #define charger_variable (charger->client)
30 #define charger_variable_t struct i2c_client
31 #endif
32
33 #include <linux/battery/sec_charging_common.h>
34 #if defined(CONFIG_FUELGAUGE_SPRD4SAMSUNG27X3) || defined(CONFIG_CHARGER_SPRD4SAMSUNG27X3)
35 #include <linux/battery/charger/sprd27x3_charger4samsung.h>
36 #endif
37
38 #if defined(CONFIG_CHARGER_DUMMY) || \
39         defined(CONFIG_CHARGER_PM8917)
40 #include <linux/battery/charger/dummy_charger.h>
41 #elif defined(CONFIG_CHARGER_MAX8903)
42 #include <linux/battery/charger/max8903_charger.h>
43 #elif defined(CONFIG_CHARGER_SMB327)
44 #include <linux/battery/charger/smb327_charger.h>
45 #elif defined(CONFIG_CHARGER_SMB328)
46 #include <linux/battery/charger/smb328_charger.h>
47 #elif defined(CONFIG_CHARGER_SMB347)
48 #include <linux/battery/charger/smb347_charger.h>
49 #elif defined(CONFIG_CHARGER_SMB358)
50 #include <linux/battery/charger/smb358_charger.h>
51 #elif defined(CONFIG_CHARGER_BQ24157)
52 #include <linux/battery/charger/bq24157_charger.h>
53 #elif defined(CONFIG_CHARGER_BQ24190) || \
54         defined(CONFIG_CHARGER_BQ24191)
55 #include <linux/battery/charger/bq24190_charger.h>
56 #elif defined(CONFIG_CHARGER_BQ24260)
57 #include <linux/battery/charger/bq24260_charger.h>
58 #elif defined(CONFIG_CHARGER_MAX77803)
59 #include <linux/battery/charger/max77803_charger.h>
60 #elif defined(CONFIG_CHARGER_NCP1851)
61 #include <linux/battery/charger/ncp1851_charger.h>
62 #elif defined(CONFIG_CHARGER_RT5033)
63 #include <linux/battery/charger/rt5033_charger.h>
64 #elif defined(CONFIG_CHARGER_RT9455)
65 #include <linux/battery/charger/rt9455_charger.h>
66 #elif defined(CONFIG_CHARGER_SM5414)
67 #include <linux/battery/charger/sm5414_charger.h>
68 #elif defined(CONFIG_CHARGER_SM5701)
69 #include <linux/battery/charger/sm5701_charger.h>
70 #endif
71
72 #if defined(CONFIG_CHARGER_SM5414)
73 extern int sec_vf_adc_check(void);
74 #endif
75
76 struct sec_charger_info {
77         struct i2c_client               *client;
78         sec_battery_platform_data_t *pdata;
79         struct power_supply             psy_chg;
80         struct delayed_work isr_work;
81
82         struct workqueue_struct *wq;
83         struct delayed_work delayed_work;
84
85         int cable_type;
86         int status;
87         bool is_charging;
88         int health;
89         /* HW-dedicated charger info structure
90          * used in individual charger file only
91          * (ex. dummy_charger.c)
92          */
93 #if defined(CONFIG_BATTERY_SAMSUNG) && defined(CONFIG_CHARGER_BQ24157)
94         struct sec_chg_info info;
95 #endif
96
97 #if defined(CONFIG_CHARGER_SM5414)
98         struct sec_chg_info sm5414_chg_inf;
99         bool is_fullcharged;
100 #endif
101
102         /* charging current : + charging, - OTG */
103         int charging_current;
104         int input_current_limit;
105         unsigned charging_current_max;
106
107         /* register programming */
108         int reg_addr;
109         int reg_data;
110         int irq_base;
111         int siop_level;
112         bool is_slow_charging;
113         struct delayed_work slow_work;
114 };
115
116 #if defined(CONFIG_CHARGER_SPRD4SAMSUNG27X3) && \
117         !defined(CONFIG_CHARGER_SM5414) && \
118         !defined(CONFIG_CHARGER_SMB328)
119 bool sec_hal_chg_init(charger_variable_t *);
120 bool sec_hal_chg_suspend(charger_variable_t *);
121 bool sec_hal_chg_resume(charger_variable_t *);
122 bool sec_hal_chg_get_property(charger_variable_t *,
123                                 enum power_supply_property,
124                                 union power_supply_propval *);
125 bool sec_hal_chg_set_property(charger_variable_t *,
126                                 enum power_supply_property,
127                                 const union power_supply_propval *);
128 #else
129 bool sec_hal_chg_init(struct i2c_client *);
130 bool sec_hal_chg_suspend(struct i2c_client *);
131 bool sec_hal_chg_resume(struct i2c_client *);
132 bool sec_hal_chg_shutdown(struct i2c_client *);
133 bool sec_hal_chg_get_property(struct i2c_client *,
134                 enum power_supply_property,
135                 union power_supply_propval *);
136 bool sec_hal_chg_set_property(struct i2c_client *,
137                 enum power_supply_property,
138                 const union power_supply_propval *);
139 #if defined(CONFIG_CHARGER_SM5414)
140         int sec_get_charging_health(struct i2c_client *client);
141 #endif
142 #endif
143
144 ssize_t sec_hal_chg_show_attrs(struct device *dev,
145                 const ptrdiff_t offset, char *buf);
146
147 ssize_t sec_hal_chg_store_attrs(struct device *dev,
148                 const ptrdiff_t offset,
149                 const char *buf, size_t count);
150
151 ssize_t sec_chg_show_attrs(struct device *dev,
152                 struct device_attribute *attr, char *buf);
153
154 ssize_t sec_chg_store_attrs(struct device *dev,
155                 struct device_attribute *attr,
156                 const char *buf, size_t count);
157
158 #define SEC_CHARGER_ATTR(_name)                         \
159 {                                                       \
160         .attr = {.name = #_name, .mode = 0664}, \
161         .show = sec_chg_show_attrs,                     \
162         .store = sec_chg_store_attrs,                   \
163 }
164
165 /* never declare static varibles in header files
166    static struct device_attribute sec_charger_attrs[] = {
167    SEC_CHARGER_ATTR(reg),
168    SEC_CHARGER_ATTR(data),
169    SEC_CHARGER_ATTR(regs),
170    };*/
171
172 enum {
173         CHG_REG = 0,
174         CHG_DATA,
175         CHG_REGS,
176 };
177 #if defined(CONFIG_CHARGER_SMB358)
178 extern sec_battery_platform_data_t sec_battery_pdata;
179 #endif
180 #endif /* __SEC_CHARGER_H */