blob: 5be985e09f88251998ddd323413ae6b05da6989e [file] [log] [blame]
Harry Yang4b7db0f2017-11-27 10:50:44 -08001/* Copyright (c) 2018 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#ifndef __SMB5_CHARGER_H
14#define __SMB5_CHARGER_H
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/irqreturn.h>
18#include <linux/regulator/driver.h>
19#include <linux/regulator/consumer.h>
20#include <linux/extcon.h>
21#include "storm-watch.h"
22
23enum print_reason {
24 PR_INTERRUPT = BIT(0),
25 PR_REGISTER = BIT(1),
26 PR_MISC = BIT(2),
27 PR_PARALLEL = BIT(3),
28 PR_OTG = BIT(4),
29};
30
31#define DEFAULT_VOTER "DEFAULT_VOTER"
32#define USER_VOTER "USER_VOTER"
33#define PD_VOTER "PD_VOTER"
34#define DCP_VOTER "DCP_VOTER"
35#define QC_VOTER "QC_VOTER"
36#define PL_USBIN_USBIN_VOTER "PL_USBIN_USBIN_VOTER"
37#define USB_PSY_VOTER "USB_PSY_VOTER"
38#define PL_TAPER_WORK_RUNNING_VOTER "PL_TAPER_WORK_RUNNING_VOTER"
39#define PL_QNOVO_VOTER "PL_QNOVO_VOTER"
40#define USBIN_V_VOTER "USBIN_V_VOTER"
41#define CHG_STATE_VOTER "CHG_STATE_VOTER"
42#define TYPEC_SRC_VOTER "TYPEC_SRC_VOTER"
43#define TAPER_END_VOTER "TAPER_END_VOTER"
44#define THERMAL_DAEMON_VOTER "THERMAL_DAEMON_VOTER"
45#define CC_DETACHED_VOTER "CC_DETACHED_VOTER"
46#define APSD_VOTER "APSD_VOTER"
47#define PD_DISALLOWED_INDIRECT_VOTER "PD_DISALLOWED_INDIRECT_VOTER"
48#define VBUS_CC_SHORT_VOTER "VBUS_CC_SHORT_VOTER"
49#define PD_INACTIVE_VOTER "PD_INACTIVE_VOTER"
50#define BOOST_BACK_VOTER "BOOST_BACK_VOTER"
51#define USBIN_USBIN_BOOST_VOTER "USBIN_USBIN_BOOST_VOTER"
52#define MICRO_USB_VOTER "MICRO_USB_VOTER"
53#define DEBUG_BOARD_VOTER "DEBUG_BOARD_VOTER"
54#define PD_SUSPEND_SUPPORTED_VOTER "PD_SUSPEND_SUPPORTED_VOTER"
55#define PL_DELAY_VOTER "PL_DELAY_VOTER"
56#define CTM_VOTER "CTM_VOTER"
57#define SW_QC3_VOTER "SW_QC3_VOTER"
58#define AICL_RERUN_VOTER "AICL_RERUN_VOTER"
Harry Yangf7b89902018-03-13 22:37:53 -070059#define SW_ICL_MAX_VOTER "SW_ICL_MAX_VOTER"
Harry Yang4b7db0f2017-11-27 10:50:44 -080060#define QNOVO_VOTER "QNOVO_VOTER"
61#define BATT_PROFILE_VOTER "BATT_PROFILE_VOTER"
62#define OTG_DELAY_VOTER "OTG_DELAY_VOTER"
63#define USBIN_I_VOTER "USBIN_I_VOTER"
64#define WEAK_CHARGER_VOTER "WEAK_CHARGER_VOTER"
65#define OTG_VOTER "OTG_VOTER"
66#define PL_FCC_LOW_VOTER "PL_FCC_LOW_VOTER"
67#define WBC_VOTER "WBC_VOTER"
68#define HW_LIMIT_VOTER "HW_LIMIT_VOTER"
Anirudh Ghayaldfdb8412018-04-21 10:37:18 +053069#define FORCE_RECHARGE_VOTER "FORCE_RECHARGE_VOTER"
Ashay Jaiswale0b3c472018-06-20 23:39:41 +053070#define AICL_THRESHOLD_VOTER "AICL_THRESHOLD_VOTER"
Harry Yang4b7db0f2017-11-27 10:50:44 -080071
72#define BOOST_BACK_STORM_COUNT 3
73#define WEAK_CHG_STORM_COUNT 8
74
Anirudh Ghayal1380d312018-02-23 00:01:43 +053075#define VBAT_TO_VRAW_ADC(v) div_u64((u64)v * 1000000UL, 194637UL)
76
Anirudh Ghayal4d5cddc2018-06-28 15:19:39 +053077#define SDP_100_MA 100000
78#define SDP_CURRENT_UA 500000
79#define CDP_CURRENT_UA 1500000
80#define DCP_CURRENT_UA 1500000
81#define HVDCP_CURRENT_UA 3000000
82#define TYPEC_DEFAULT_CURRENT_UA 900000
83#define TYPEC_MEDIUM_CURRENT_UA 1500000
84#define TYPEC_HIGH_CURRENT_UA 3000000
Guru Das Srinagesh3ca14372018-06-01 11:30:56 -070085#define ADC_CHG_TERM_MASK 32767
Anirudh Ghayal4d5cddc2018-06-28 15:19:39 +053086
Harry Yang4b7db0f2017-11-27 10:50:44 -080087enum smb_mode {
88 PARALLEL_MASTER = 0,
89 PARALLEL_SLAVE,
90 NUM_MODES,
91};
92
Harry Yang6afaea22018-03-26 19:11:07 -070093enum sink_src_mode {
94 SINK_MODE,
95 SRC_MODE,
96 UNATTACHED_MODE,
97};
98
Harry Yang4b7db0f2017-11-27 10:50:44 -080099enum {
100 BOOST_BACK_WA = BIT(0),
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530101 WEAK_ADAPTER_WA = BIT(1),
102};
103
104enum {
105 RERUN_AICL = BIT(0),
106 RESTART_AICL = BIT(1),
Harry Yang4b7db0f2017-11-27 10:50:44 -0800107};
108
109enum smb_irq_index {
110 /* CHGR */
111 CHGR_ERROR_IRQ = 0,
112 CHG_STATE_CHANGE_IRQ,
113 STEP_CHG_STATE_CHANGE_IRQ,
114 STEP_CHG_SOC_UPDATE_FAIL_IRQ,
115 STEP_CHG_SOC_UPDATE_REQ_IRQ,
116 FG_FVCAL_QUALIFIED_IRQ,
117 VPH_ALARM_IRQ,
118 VPH_DROP_PRECHG_IRQ,
119 /* DCDC */
120 OTG_FAIL_IRQ,
121 OTG_OC_DISABLE_SW_IRQ,
122 OTG_OC_HICCUP_IRQ,
123 BSM_ACTIVE_IRQ,
124 HIGH_DUTY_CYCLE_IRQ,
125 INPUT_CURRENT_LIMITING_IRQ,
126 CONCURRENT_MODE_DISABLE_IRQ,
127 SWITCHER_POWER_OK_IRQ,
128 /* BATIF */
129 BAT_TEMP_IRQ,
130 ALL_CHNL_CONV_DONE_IRQ,
131 BAT_OV_IRQ,
132 BAT_LOW_IRQ,
133 BAT_THERM_OR_ID_MISSING_IRQ,
134 BAT_TERMINAL_MISSING_IRQ,
135 BUCK_OC_IRQ,
136 VPH_OV_IRQ,
137 /* USB */
138 USBIN_COLLAPSE_IRQ,
139 USBIN_VASHDN_IRQ,
140 USBIN_UV_IRQ,
141 USBIN_OV_IRQ,
142 USBIN_PLUGIN_IRQ,
143 USBIN_REVI_CHANGE_IRQ,
144 USBIN_SRC_CHANGE_IRQ,
145 USBIN_ICL_CHANGE_IRQ,
146 /* DC */
147 DCIN_VASHDN_IRQ,
148 DCIN_UV_IRQ,
149 DCIN_OV_IRQ,
150 DCIN_PLUGIN_IRQ,
151 DCIN_REVI_IRQ,
152 DCIN_PON_IRQ,
153 DCIN_EN_IRQ,
154 /* TYPEC */
155 TYPEC_OR_RID_DETECTION_CHANGE_IRQ,
156 TYPEC_VPD_DETECT_IRQ,
157 TYPEC_CC_STATE_CHANGE_IRQ,
158 TYPEC_VCONN_OC_IRQ,
159 TYPEC_VBUS_CHANGE_IRQ,
160 TYPEC_ATTACH_DETACH_IRQ,
161 TYPEC_LEGACY_CABLE_DETECT_IRQ,
162 TYPEC_TRY_SNK_SRC_DETECT_IRQ,
163 /* MISC */
164 WDOG_SNARL_IRQ,
165 WDOG_BARK_IRQ,
166 AICL_FAIL_IRQ,
167 AICL_DONE_IRQ,
168 SMB_EN_IRQ,
169 IMP_TRIGGER_IRQ,
170 TEMP_CHANGE_IRQ,
171 TEMP_CHANGE_SMB_IRQ,
Ashay Jaiswal09feab82018-02-12 12:33:18 +0530172 /* FLASH */
173 VREG_OK_IRQ,
174 ILIM_S2_IRQ,
175 ILIM_S1_IRQ,
176 VOUT_DOWN_IRQ,
177 VOUT_UP_IRQ,
178 FLASH_STATE_CHANGE_IRQ,
179 TORCH_REQ_IRQ,
180 FLASH_EN_IRQ,
Harry Yang4b7db0f2017-11-27 10:50:44 -0800181 /* END */
182 SMB_IRQ_MAX,
183};
184
185enum float_options {
186 FLOAT_DCP = 1,
187 FLOAT_SDP = 2,
188 DISABLE_CHARGING = 3,
189 SUSPEND_INPUT = 4,
190};
191
Guru Das Srinagesh3ca14372018-06-01 11:30:56 -0700192enum chg_term_config_src {
193 ITERM_SRC_UNSPECIFIED,
194 ITERM_SRC_ADC,
195 ITERM_SRC_ANALOG
196};
197
Harry Yang4b7db0f2017-11-27 10:50:44 -0800198struct smb_irq_info {
199 const char *name;
200 const irq_handler_t handler;
201 const bool wake;
202 const struct storm_watch storm_data;
203 struct smb_irq_data *irq_data;
204 int irq;
205};
206
207static const unsigned int smblib_extcon_cable[] = {
208 EXTCON_USB,
209 EXTCON_USB_HOST,
210 EXTCON_NONE,
211};
212
213/* EXTCON_USB and EXTCON_USB_HOST are mutually exclusive */
214static const u32 smblib_extcon_exclusive[] = {0x3, 0};
215
216struct smb_regulator {
217 struct regulator_dev *rdev;
218 struct regulator_desc rdesc;
219};
220
221struct smb_irq_data {
222 void *parent_data;
223 const char *name;
224 struct storm_watch storm_data;
225};
226
227struct smb_chg_param {
228 const char *name;
229 u16 reg;
230 int min_u;
231 int max_u;
232 int step_u;
233 int (*get_proc)(struct smb_chg_param *param,
234 u8 val_raw);
235 int (*set_proc)(struct smb_chg_param *param,
236 int val_u,
237 u8 *val_raw);
238};
239
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530240struct buck_boost_freq {
241 int freq_khz;
242 u8 val;
243};
244
Harry Yang4b7db0f2017-11-27 10:50:44 -0800245struct smb_chg_freq {
246 unsigned int freq_5V;
247 unsigned int freq_6V_8V;
248 unsigned int freq_9V;
249 unsigned int freq_12V;
250 unsigned int freq_removal;
251 unsigned int freq_below_otg_threshold;
252 unsigned int freq_above_otg_threshold;
253};
254
255struct smb_params {
256 struct smb_chg_param fcc;
257 struct smb_chg_param fv;
258 struct smb_chg_param usb_icl;
Harry Yangf7b89902018-03-13 22:37:53 -0700259 struct smb_chg_param icl_max_stat;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800260 struct smb_chg_param icl_stat;
261 struct smb_chg_param otg_cl;
262 struct smb_chg_param jeita_cc_comp_hot;
263 struct smb_chg_param jeita_cc_comp_cold;
264 struct smb_chg_param freq_switcher;
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530265 struct smb_chg_param aicl_5v_threshold;
266 struct smb_chg_param aicl_cont_threshold;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800267};
268
269struct parallel_params {
270 struct power_supply *psy;
271};
272
273struct smb_iio {
274 struct iio_channel *temp_chan;
275 struct iio_channel *temp_max_chan;
276 struct iio_channel *usbin_i_chan;
277 struct iio_channel *usbin_v_chan;
278 struct iio_channel *batt_i_chan;
279 struct iio_channel *connector_temp_chan;
280 struct iio_channel *connector_temp_thr1_chan;
281 struct iio_channel *connector_temp_thr2_chan;
282 struct iio_channel *connector_temp_thr3_chan;
283};
284
285struct smb_charger {
286 struct device *dev;
287 char *name;
288 struct regmap *regmap;
289 struct smb_irq_info *irq_info;
290 struct smb_params param;
291 struct smb_iio iio;
292 int *debug_mask;
Harry Yang6afaea22018-03-26 19:11:07 -0700293 int *pd_disabled;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800294 enum smb_mode mode;
295 struct smb_chg_freq chg_freq;
296 int smb_version;
297 int otg_delay_ms;
298 int *weak_chg_icl_ua;
Ashay Jaiswal20688262018-04-25 11:45:34 +0530299 struct qpnp_vadc_chip *vadc_dev;
Ashay Jaiswalf2ca7092018-05-22 21:33:15 +0530300 bool pd_not_supported;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800301
302 /* locks */
303 struct mutex lock;
304 struct mutex ps_change_lock;
Anirudh Ghayal75f8f812018-07-09 16:48:47 +0530305 struct mutex vadc_lock;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800306
307 /* power supplies */
308 struct power_supply *batt_psy;
309 struct power_supply *usb_psy;
310 struct power_supply *dc_psy;
311 struct power_supply *bms_psy;
312 struct power_supply *usb_main_psy;
313 struct power_supply *usb_port_psy;
314 enum power_supply_type real_charger_type;
315
316 /* notifiers */
317 struct notifier_block nb;
318
319 /* parallel charging */
320 struct parallel_params pl;
321
322 /* regulators */
323 struct smb_regulator *vbus_vreg;
324 struct smb_regulator *vconn_vreg;
325 struct regulator *dpdm_reg;
326
327 /* votables */
328 struct votable *dc_suspend_votable;
329 struct votable *fcc_votable;
330 struct votable *fv_votable;
331 struct votable *usb_icl_votable;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800332 struct votable *awake_votable;
333 struct votable *pl_disable_votable;
334 struct votable *chg_disable_votable;
335 struct votable *pl_enable_votable_indirect;
336 struct votable *usb_irq_enable_votable;
337
338 /* work */
339 struct work_struct bms_update_work;
340 struct work_struct pl_update_work;
Ashay Jaiswalf05bd552018-04-12 18:11:00 +0530341 struct work_struct jeita_update_work;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800342 struct delayed_work ps_change_timeout_work;
343 struct delayed_work clear_hdc_work;
344 struct delayed_work icl_change_work;
345 struct delayed_work pl_enable_work;
346 struct delayed_work uusb_otg_work;
347 struct delayed_work bb_removal_work;
348
Harry Yang6afaea22018-03-26 19:11:07 -0700349 /* pd */
Harry Yang4b7db0f2017-11-27 10:50:44 -0800350 int voltage_min_uv;
351 int voltage_max_uv;
352 int pd_active;
Harry Yang6afaea22018-03-26 19:11:07 -0700353 bool pd_hard_reset;
354 bool pr_swap_in_progress;
355 bool early_usb_attach;
356 bool ok_to_pd;
357 bool typec_legacy;
358
359 /* cached status */
Harry Yang4b7db0f2017-11-27 10:50:44 -0800360 bool system_suspend_supported;
361 int boost_threshold_ua;
362 int system_temp_level;
363 int thermal_levels;
364 int *thermal_mitigation;
365 int dcp_icl_ua;
366 int fake_capacity;
367 int fake_batt_status;
368 bool step_chg_enabled;
369 bool sw_jeita_enabled;
370 bool is_hdc;
371 bool chg_done;
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530372 int connector_type;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800373 bool otg_en;
374 bool suspend_input_on_debug_batt;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800375 int default_icl_ua;
376 int otg_cl_ua;
377 bool uusb_apsd_rerun_done;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800378 int fake_input_current_limited;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800379 int typec_mode;
380 int usb_icl_change_irq_enabled;
381 u32 jeita_status;
382 u8 float_cfg;
383 bool use_extcon;
384 bool otg_present;
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530385 int hw_max_icl_ua;
Anirudh Ghayal1380d312018-02-23 00:01:43 +0530386 int auto_recharge_soc;
Ashay Jaiswalf05bd552018-04-12 18:11:00 +0530387 bool jeita_configured;
Harry Yang6afaea22018-03-26 19:11:07 -0700388 enum sink_src_mode sink_src_mode;
Ashay Jaiswal0de6fb92018-06-12 17:23:45 +0530389 bool hw_die_temp_mitigation;
390 bool hw_connector_mitigation;
391 int connector_pull_up;
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530392 int aicl_5v_threshold_mv;
393 int default_aicl_5v_threshold_mv;
394 int aicl_cont_threshold_mv;
395 int default_aicl_cont_threshold_mv;
396 bool aicl_max_reached;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800397
398 /* workaround flag */
399 u32 wa_flags;
400 int boost_current_ua;
401
402 /* extcon for VBUS / ID notification to USB for uUSB */
403 struct extcon_dev *extcon;
404
405 /* battery profile */
406 int batt_profile_fcc_ua;
407 int batt_profile_fv_uv;
408
409 int usb_icl_delta_ua;
410 int pulse_cnt;
411
412 int die_health;
Ashay Jaiswal09feab82018-02-12 12:33:18 +0530413
414 /* flash */
415 u32 flash_derating_soc;
416 u32 flash_disable_soc;
417 u32 headroom_mode;
418 bool flash_init_done;
419 bool flash_active;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800420};
421
422int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
423int smblib_masked_write(struct smb_charger *chg, u16 addr, u8 mask, u8 val);
424int smblib_write(struct smb_charger *chg, u16 addr, u8 val);
Anirudh Ghayal1380d312018-02-23 00:01:43 +0530425int smblib_batch_write(struct smb_charger *chg, u16 addr, u8 *val, int count);
426int smblib_batch_read(struct smb_charger *chg, u16 addr, u8 *val, int count);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800427
428int smblib_get_charge_param(struct smb_charger *chg,
429 struct smb_chg_param *param, int *val_u);
430int smblib_get_usb_suspend(struct smb_charger *chg, int *suspend);
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530431int smblib_get_aicl_cont_threshold(struct smb_chg_param *param, u8 val_raw);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800432int smblib_enable_charging(struct smb_charger *chg, bool enable);
433int smblib_set_charge_param(struct smb_charger *chg,
434 struct smb_chg_param *param, int val_u);
435int smblib_set_usb_suspend(struct smb_charger *chg, bool suspend);
436int smblib_set_dc_suspend(struct smb_charger *chg, bool suspend);
437
438int smblib_mapping_soc_from_field_value(struct smb_chg_param *param,
439 int val_u, u8 *val_raw);
440int smblib_mapping_cc_delta_to_field_value(struct smb_chg_param *param,
441 u8 val_raw);
442int smblib_mapping_cc_delta_from_field_value(struct smb_chg_param *param,
443 int val_u, u8 *val_raw);
444int smblib_set_chg_freq(struct smb_chg_param *param,
445 int val_u, u8 *val_raw);
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530446int smblib_set_prop_boost_current(struct smb_charger *chg,
447 const union power_supply_propval *val);
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530448int smblib_set_aicl_cont_threshold(struct smb_chg_param *param,
449 int val_u, u8 *val_raw);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800450int smblib_vbus_regulator_enable(struct regulator_dev *rdev);
451int smblib_vbus_regulator_disable(struct regulator_dev *rdev);
452int smblib_vbus_regulator_is_enabled(struct regulator_dev *rdev);
453
454int smblib_vconn_regulator_enable(struct regulator_dev *rdev);
455int smblib_vconn_regulator_disable(struct regulator_dev *rdev);
456int smblib_vconn_regulator_is_enabled(struct regulator_dev *rdev);
457
458irqreturn_t default_irq_handler(int irq, void *data);
459irqreturn_t chg_state_change_irq_handler(int irq, void *data);
460irqreturn_t batt_temp_changed_irq_handler(int irq, void *data);
461irqreturn_t batt_psy_changed_irq_handler(int irq, void *data);
462irqreturn_t usbin_uv_irq_handler(int irq, void *data);
463irqreturn_t usb_plugin_irq_handler(int irq, void *data);
464irqreturn_t usb_source_change_irq_handler(int irq, void *data);
465irqreturn_t icl_change_irq_handler(int irq, void *data);
466irqreturn_t typec_state_change_irq_handler(int irq, void *data);
Harry Yang6afaea22018-03-26 19:11:07 -0700467irqreturn_t typec_attach_detach_irq_handler(int irq, void *data);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800468irqreturn_t dc_plugin_irq_handler(int irq, void *data);
469irqreturn_t high_duty_cycle_irq_handler(int irq, void *data);
470irqreturn_t switcher_power_ok_irq_handler(int irq, void *data);
471irqreturn_t wdog_bark_irq_handler(int irq, void *data);
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530472irqreturn_t typec_or_rid_detection_change_irq_handler(int irq, void *data);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800473
474int smblib_get_prop_input_suspend(struct smb_charger *chg,
475 union power_supply_propval *val);
476int smblib_get_prop_batt_present(struct smb_charger *chg,
477 union power_supply_propval *val);
478int smblib_get_prop_batt_capacity(struct smb_charger *chg,
479 union power_supply_propval *val);
480int smblib_get_prop_batt_status(struct smb_charger *chg,
481 union power_supply_propval *val);
482int smblib_get_prop_batt_charge_type(struct smb_charger *chg,
483 union power_supply_propval *val);
484int smblib_get_prop_batt_charge_done(struct smb_charger *chg,
485 union power_supply_propval *val);
486int smblib_get_prop_batt_health(struct smb_charger *chg,
487 union power_supply_propval *val);
488int smblib_get_prop_system_temp_level(struct smb_charger *chg,
489 union power_supply_propval *val);
490int smblib_get_prop_system_temp_level_max(struct smb_charger *chg,
491 union power_supply_propval *val);
492int smblib_get_prop_input_current_limited(struct smb_charger *chg,
493 union power_supply_propval *val);
494int smblib_get_prop_batt_voltage_now(struct smb_charger *chg,
495 union power_supply_propval *val);
496int smblib_get_prop_batt_current_now(struct smb_charger *chg,
497 union power_supply_propval *val);
Guru Das Srinagesh3ca14372018-06-01 11:30:56 -0700498int smblib_get_prop_batt_iterm(struct smb_charger *chg,
499 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800500int smblib_get_prop_batt_temp(struct smb_charger *chg,
501 union power_supply_propval *val);
502int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
503 union power_supply_propval *val);
Subbaraman Narayanamurthyc4feb892018-05-07 18:43:45 -0700504int smblib_get_prop_batt_cycle_count(struct smb_charger *chg,
505 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800506int smblib_set_prop_input_suspend(struct smb_charger *chg,
507 const union power_supply_propval *val);
508int smblib_set_prop_batt_capacity(struct smb_charger *chg,
509 const union power_supply_propval *val);
510int smblib_set_prop_batt_status(struct smb_charger *chg,
511 const union power_supply_propval *val);
512int smblib_set_prop_system_temp_level(struct smb_charger *chg,
513 const union power_supply_propval *val);
514int smblib_set_prop_input_current_limited(struct smb_charger *chg,
515 const union power_supply_propval *val);
516
517int smblib_get_prop_dc_present(struct smb_charger *chg,
518 union power_supply_propval *val);
519int smblib_get_prop_dc_online(struct smb_charger *chg,
520 union power_supply_propval *val);
521int smblib_get_prop_dc_current_max(struct smb_charger *chg,
522 union power_supply_propval *val);
523int smblib_set_prop_dc_current_max(struct smb_charger *chg,
524 const union power_supply_propval *val);
525int smblib_get_prop_usb_present(struct smb_charger *chg,
526 union power_supply_propval *val);
527int smblib_get_prop_usb_online(struct smb_charger *chg,
528 union power_supply_propval *val);
529int smblib_get_prop_usb_suspend(struct smb_charger *chg,
530 union power_supply_propval *val);
531int smblib_get_prop_usb_voltage_max(struct smb_charger *chg,
532 union power_supply_propval *val);
Umang Agrawal9fb865a2018-06-25 16:24:00 +0530533int smblib_get_prop_usb_voltage_max_design(struct smb_charger *chg,
534 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800535int smblib_get_prop_typec_cc_orientation(struct smb_charger *chg,
536 union power_supply_propval *val);
537int smblib_get_prop_typec_power_role(struct smb_charger *chg,
538 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800539int smblib_get_prop_input_current_settled(struct smb_charger *chg,
540 union power_supply_propval *val);
541int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
542 union power_supply_propval *val);
543int smblib_get_prop_pd_in_hard_reset(struct smb_charger *chg,
544 union power_supply_propval *val);
545int smblib_get_pe_start(struct smb_charger *chg,
546 union power_supply_propval *val);
547int smblib_get_prop_die_health(struct smb_charger *chg,
548 union power_supply_propval *val);
549int smblib_set_prop_pd_current_max(struct smb_charger *chg,
550 const union power_supply_propval *val);
551int smblib_set_prop_sdp_current_max(struct smb_charger *chg,
552 const union power_supply_propval *val);
553int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
554 const union power_supply_propval *val);
555int smblib_set_prop_pd_voltage_min(struct smb_charger *chg,
556 const union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800557int smblib_set_prop_typec_power_role(struct smb_charger *chg,
558 const union power_supply_propval *val);
559int smblib_set_prop_pd_active(struct smb_charger *chg,
560 const union power_supply_propval *val);
561int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
562 const union power_supply_propval *val);
563int smblib_set_prop_ship_mode(struct smb_charger *chg,
564 const union power_supply_propval *val);
565void smblib_suspend_on_debug_battery(struct smb_charger *chg);
566int smblib_rerun_apsd_if_required(struct smb_charger *chg);
567int smblib_get_prop_fcc_delta(struct smb_charger *chg,
568 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800569int smblib_dp_dm(struct smb_charger *chg, int val);
570int smblib_disable_hw_jeita(struct smb_charger *chg, bool disable);
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530571int smblib_run_aicl(struct smb_charger *chg, int type);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800572int smblib_set_icl_current(struct smb_charger *chg, int icl_ua);
573int smblib_get_icl_current(struct smb_charger *chg, int *icl_ua);
574int smblib_get_charge_current(struct smb_charger *chg, int *total_current_ua);
575int smblib_get_prop_pr_swap_in_progress(struct smb_charger *chg,
576 union power_supply_propval *val);
577int smblib_set_prop_pr_swap_in_progress(struct smb_charger *chg,
578 const union power_supply_propval *val);
579int smblib_stat_sw_override_cfg(struct smb_charger *chg, bool override);
Ashay Jaiswala55b7ed2018-03-23 17:23:48 +0530580int smblib_configure_wdog(struct smb_charger *chg, bool enable);
Ashay Jaiswal4d334f42018-04-25 10:58:49 +0530581int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val);
Ashay Jaiswalc96380de2018-05-16 12:02:36 +0530582int smblib_configure_hvdcp_apsd(struct smb_charger *chg, bool enable);
Ashay Jaiswalcbdf2e82018-05-27 23:59:01 +0530583int smblib_icl_override(struct smb_charger *chg, bool override);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800584
585int smblib_init(struct smb_charger *chg);
586int smblib_deinit(struct smb_charger *chg);
587#endif /* __SMB5_CHARGER_H */