blob: e59b11b153760130fde6a8958c3e32efaf49bd34 [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
85
Harry Yang4b7db0f2017-11-27 10:50:44 -080086enum smb_mode {
87 PARALLEL_MASTER = 0,
88 PARALLEL_SLAVE,
89 NUM_MODES,
90};
91
Harry Yang6afaea22018-03-26 19:11:07 -070092enum sink_src_mode {
93 SINK_MODE,
94 SRC_MODE,
95 UNATTACHED_MODE,
96};
97
Harry Yang4b7db0f2017-11-27 10:50:44 -080098enum {
99 BOOST_BACK_WA = BIT(0),
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530100 WEAK_ADAPTER_WA = BIT(1),
101};
102
103enum {
104 RERUN_AICL = BIT(0),
105 RESTART_AICL = BIT(1),
Harry Yang4b7db0f2017-11-27 10:50:44 -0800106};
107
108enum smb_irq_index {
109 /* CHGR */
110 CHGR_ERROR_IRQ = 0,
111 CHG_STATE_CHANGE_IRQ,
112 STEP_CHG_STATE_CHANGE_IRQ,
113 STEP_CHG_SOC_UPDATE_FAIL_IRQ,
114 STEP_CHG_SOC_UPDATE_REQ_IRQ,
115 FG_FVCAL_QUALIFIED_IRQ,
116 VPH_ALARM_IRQ,
117 VPH_DROP_PRECHG_IRQ,
118 /* DCDC */
119 OTG_FAIL_IRQ,
120 OTG_OC_DISABLE_SW_IRQ,
121 OTG_OC_HICCUP_IRQ,
122 BSM_ACTIVE_IRQ,
123 HIGH_DUTY_CYCLE_IRQ,
124 INPUT_CURRENT_LIMITING_IRQ,
125 CONCURRENT_MODE_DISABLE_IRQ,
126 SWITCHER_POWER_OK_IRQ,
127 /* BATIF */
128 BAT_TEMP_IRQ,
129 ALL_CHNL_CONV_DONE_IRQ,
130 BAT_OV_IRQ,
131 BAT_LOW_IRQ,
132 BAT_THERM_OR_ID_MISSING_IRQ,
133 BAT_TERMINAL_MISSING_IRQ,
134 BUCK_OC_IRQ,
135 VPH_OV_IRQ,
136 /* USB */
137 USBIN_COLLAPSE_IRQ,
138 USBIN_VASHDN_IRQ,
139 USBIN_UV_IRQ,
140 USBIN_OV_IRQ,
141 USBIN_PLUGIN_IRQ,
142 USBIN_REVI_CHANGE_IRQ,
143 USBIN_SRC_CHANGE_IRQ,
144 USBIN_ICL_CHANGE_IRQ,
145 /* DC */
146 DCIN_VASHDN_IRQ,
147 DCIN_UV_IRQ,
148 DCIN_OV_IRQ,
149 DCIN_PLUGIN_IRQ,
150 DCIN_REVI_IRQ,
151 DCIN_PON_IRQ,
152 DCIN_EN_IRQ,
153 /* TYPEC */
154 TYPEC_OR_RID_DETECTION_CHANGE_IRQ,
155 TYPEC_VPD_DETECT_IRQ,
156 TYPEC_CC_STATE_CHANGE_IRQ,
157 TYPEC_VCONN_OC_IRQ,
158 TYPEC_VBUS_CHANGE_IRQ,
159 TYPEC_ATTACH_DETACH_IRQ,
160 TYPEC_LEGACY_CABLE_DETECT_IRQ,
161 TYPEC_TRY_SNK_SRC_DETECT_IRQ,
162 /* MISC */
163 WDOG_SNARL_IRQ,
164 WDOG_BARK_IRQ,
165 AICL_FAIL_IRQ,
166 AICL_DONE_IRQ,
167 SMB_EN_IRQ,
168 IMP_TRIGGER_IRQ,
169 TEMP_CHANGE_IRQ,
170 TEMP_CHANGE_SMB_IRQ,
Ashay Jaiswal09feab82018-02-12 12:33:18 +0530171 /* FLASH */
172 VREG_OK_IRQ,
173 ILIM_S2_IRQ,
174 ILIM_S1_IRQ,
175 VOUT_DOWN_IRQ,
176 VOUT_UP_IRQ,
177 FLASH_STATE_CHANGE_IRQ,
178 TORCH_REQ_IRQ,
179 FLASH_EN_IRQ,
Harry Yang4b7db0f2017-11-27 10:50:44 -0800180 /* END */
181 SMB_IRQ_MAX,
182};
183
184enum float_options {
185 FLOAT_DCP = 1,
186 FLOAT_SDP = 2,
187 DISABLE_CHARGING = 3,
188 SUSPEND_INPUT = 4,
189};
190
191struct smb_irq_info {
192 const char *name;
193 const irq_handler_t handler;
194 const bool wake;
195 const struct storm_watch storm_data;
196 struct smb_irq_data *irq_data;
197 int irq;
198};
199
200static const unsigned int smblib_extcon_cable[] = {
201 EXTCON_USB,
202 EXTCON_USB_HOST,
203 EXTCON_NONE,
204};
205
206/* EXTCON_USB and EXTCON_USB_HOST are mutually exclusive */
207static const u32 smblib_extcon_exclusive[] = {0x3, 0};
208
209struct smb_regulator {
210 struct regulator_dev *rdev;
211 struct regulator_desc rdesc;
212};
213
214struct smb_irq_data {
215 void *parent_data;
216 const char *name;
217 struct storm_watch storm_data;
218};
219
220struct smb_chg_param {
221 const char *name;
222 u16 reg;
223 int min_u;
224 int max_u;
225 int step_u;
226 int (*get_proc)(struct smb_chg_param *param,
227 u8 val_raw);
228 int (*set_proc)(struct smb_chg_param *param,
229 int val_u,
230 u8 *val_raw);
231};
232
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530233struct buck_boost_freq {
234 int freq_khz;
235 u8 val;
236};
237
Harry Yang4b7db0f2017-11-27 10:50:44 -0800238struct smb_chg_freq {
239 unsigned int freq_5V;
240 unsigned int freq_6V_8V;
241 unsigned int freq_9V;
242 unsigned int freq_12V;
243 unsigned int freq_removal;
244 unsigned int freq_below_otg_threshold;
245 unsigned int freq_above_otg_threshold;
246};
247
248struct smb_params {
249 struct smb_chg_param fcc;
250 struct smb_chg_param fv;
251 struct smb_chg_param usb_icl;
Harry Yangf7b89902018-03-13 22:37:53 -0700252 struct smb_chg_param icl_max_stat;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800253 struct smb_chg_param icl_stat;
254 struct smb_chg_param otg_cl;
255 struct smb_chg_param jeita_cc_comp_hot;
256 struct smb_chg_param jeita_cc_comp_cold;
257 struct smb_chg_param freq_switcher;
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530258 struct smb_chg_param aicl_5v_threshold;
259 struct smb_chg_param aicl_cont_threshold;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800260};
261
262struct parallel_params {
263 struct power_supply *psy;
264};
265
266struct smb_iio {
267 struct iio_channel *temp_chan;
268 struct iio_channel *temp_max_chan;
269 struct iio_channel *usbin_i_chan;
270 struct iio_channel *usbin_v_chan;
271 struct iio_channel *batt_i_chan;
272 struct iio_channel *connector_temp_chan;
273 struct iio_channel *connector_temp_thr1_chan;
274 struct iio_channel *connector_temp_thr2_chan;
275 struct iio_channel *connector_temp_thr3_chan;
276};
277
278struct smb_charger {
279 struct device *dev;
280 char *name;
281 struct regmap *regmap;
282 struct smb_irq_info *irq_info;
283 struct smb_params param;
284 struct smb_iio iio;
285 int *debug_mask;
Harry Yang6afaea22018-03-26 19:11:07 -0700286 int *pd_disabled;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800287 enum smb_mode mode;
288 struct smb_chg_freq chg_freq;
289 int smb_version;
290 int otg_delay_ms;
291 int *weak_chg_icl_ua;
Ashay Jaiswal20688262018-04-25 11:45:34 +0530292 struct qpnp_vadc_chip *vadc_dev;
Ashay Jaiswalf2ca7092018-05-22 21:33:15 +0530293 bool pd_not_supported;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800294
295 /* locks */
296 struct mutex lock;
297 struct mutex ps_change_lock;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800298
299 /* power supplies */
300 struct power_supply *batt_psy;
301 struct power_supply *usb_psy;
302 struct power_supply *dc_psy;
303 struct power_supply *bms_psy;
304 struct power_supply *usb_main_psy;
305 struct power_supply *usb_port_psy;
306 enum power_supply_type real_charger_type;
307
308 /* notifiers */
309 struct notifier_block nb;
310
311 /* parallel charging */
312 struct parallel_params pl;
313
314 /* regulators */
315 struct smb_regulator *vbus_vreg;
316 struct smb_regulator *vconn_vreg;
317 struct regulator *dpdm_reg;
318
319 /* votables */
320 struct votable *dc_suspend_votable;
321 struct votable *fcc_votable;
322 struct votable *fv_votable;
323 struct votable *usb_icl_votable;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800324 struct votable *awake_votable;
325 struct votable *pl_disable_votable;
326 struct votable *chg_disable_votable;
327 struct votable *pl_enable_votable_indirect;
328 struct votable *usb_irq_enable_votable;
329
330 /* work */
331 struct work_struct bms_update_work;
332 struct work_struct pl_update_work;
Ashay Jaiswalf05bd552018-04-12 18:11:00 +0530333 struct work_struct jeita_update_work;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800334 struct delayed_work ps_change_timeout_work;
335 struct delayed_work clear_hdc_work;
336 struct delayed_work icl_change_work;
337 struct delayed_work pl_enable_work;
338 struct delayed_work uusb_otg_work;
339 struct delayed_work bb_removal_work;
340
Harry Yang6afaea22018-03-26 19:11:07 -0700341 /* pd */
Harry Yang4b7db0f2017-11-27 10:50:44 -0800342 int voltage_min_uv;
343 int voltage_max_uv;
344 int pd_active;
Harry Yang6afaea22018-03-26 19:11:07 -0700345 bool pd_hard_reset;
346 bool pr_swap_in_progress;
347 bool early_usb_attach;
348 bool ok_to_pd;
349 bool typec_legacy;
350
351 /* cached status */
Harry Yang4b7db0f2017-11-27 10:50:44 -0800352 bool system_suspend_supported;
353 int boost_threshold_ua;
354 int system_temp_level;
355 int thermal_levels;
356 int *thermal_mitigation;
357 int dcp_icl_ua;
358 int fake_capacity;
359 int fake_batt_status;
360 bool step_chg_enabled;
361 bool sw_jeita_enabled;
362 bool is_hdc;
363 bool chg_done;
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530364 int connector_type;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800365 bool otg_en;
366 bool suspend_input_on_debug_batt;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800367 int default_icl_ua;
368 int otg_cl_ua;
369 bool uusb_apsd_rerun_done;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800370 int fake_input_current_limited;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800371 int typec_mode;
372 int usb_icl_change_irq_enabled;
373 u32 jeita_status;
374 u8 float_cfg;
375 bool use_extcon;
376 bool otg_present;
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530377 int hw_max_icl_ua;
Anirudh Ghayal1380d312018-02-23 00:01:43 +0530378 int auto_recharge_soc;
Ashay Jaiswalf05bd552018-04-12 18:11:00 +0530379 bool jeita_configured;
Harry Yang6afaea22018-03-26 19:11:07 -0700380 enum sink_src_mode sink_src_mode;
Ashay Jaiswal0de6fb92018-06-12 17:23:45 +0530381 bool hw_die_temp_mitigation;
382 bool hw_connector_mitigation;
383 int connector_pull_up;
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530384 int aicl_5v_threshold_mv;
385 int default_aicl_5v_threshold_mv;
386 int aicl_cont_threshold_mv;
387 int default_aicl_cont_threshold_mv;
388 bool aicl_max_reached;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800389
390 /* workaround flag */
391 u32 wa_flags;
392 int boost_current_ua;
393
394 /* extcon for VBUS / ID notification to USB for uUSB */
395 struct extcon_dev *extcon;
396
397 /* battery profile */
398 int batt_profile_fcc_ua;
399 int batt_profile_fv_uv;
400
401 int usb_icl_delta_ua;
402 int pulse_cnt;
403
404 int die_health;
Ashay Jaiswal09feab82018-02-12 12:33:18 +0530405
406 /* flash */
407 u32 flash_derating_soc;
408 u32 flash_disable_soc;
409 u32 headroom_mode;
410 bool flash_init_done;
411 bool flash_active;
Harry Yang4b7db0f2017-11-27 10:50:44 -0800412};
413
414int smblib_read(struct smb_charger *chg, u16 addr, u8 *val);
415int smblib_masked_write(struct smb_charger *chg, u16 addr, u8 mask, u8 val);
416int smblib_write(struct smb_charger *chg, u16 addr, u8 val);
Anirudh Ghayal1380d312018-02-23 00:01:43 +0530417int smblib_batch_write(struct smb_charger *chg, u16 addr, u8 *val, int count);
418int smblib_batch_read(struct smb_charger *chg, u16 addr, u8 *val, int count);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800419
420int smblib_get_charge_param(struct smb_charger *chg,
421 struct smb_chg_param *param, int *val_u);
422int smblib_get_usb_suspend(struct smb_charger *chg, int *suspend);
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530423int smblib_get_aicl_cont_threshold(struct smb_chg_param *param, u8 val_raw);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800424int smblib_enable_charging(struct smb_charger *chg, bool enable);
425int smblib_set_charge_param(struct smb_charger *chg,
426 struct smb_chg_param *param, int val_u);
427int smblib_set_usb_suspend(struct smb_charger *chg, bool suspend);
428int smblib_set_dc_suspend(struct smb_charger *chg, bool suspend);
429
430int smblib_mapping_soc_from_field_value(struct smb_chg_param *param,
431 int val_u, u8 *val_raw);
432int smblib_mapping_cc_delta_to_field_value(struct smb_chg_param *param,
433 u8 val_raw);
434int smblib_mapping_cc_delta_from_field_value(struct smb_chg_param *param,
435 int val_u, u8 *val_raw);
436int smblib_set_chg_freq(struct smb_chg_param *param,
437 int val_u, u8 *val_raw);
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530438int smblib_set_prop_boost_current(struct smb_charger *chg,
439 const union power_supply_propval *val);
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530440int smblib_set_aicl_cont_threshold(struct smb_chg_param *param,
441 int val_u, u8 *val_raw);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800442int smblib_vbus_regulator_enable(struct regulator_dev *rdev);
443int smblib_vbus_regulator_disable(struct regulator_dev *rdev);
444int smblib_vbus_regulator_is_enabled(struct regulator_dev *rdev);
445
446int smblib_vconn_regulator_enable(struct regulator_dev *rdev);
447int smblib_vconn_regulator_disable(struct regulator_dev *rdev);
448int smblib_vconn_regulator_is_enabled(struct regulator_dev *rdev);
449
450irqreturn_t default_irq_handler(int irq, void *data);
451irqreturn_t chg_state_change_irq_handler(int irq, void *data);
452irqreturn_t batt_temp_changed_irq_handler(int irq, void *data);
453irqreturn_t batt_psy_changed_irq_handler(int irq, void *data);
454irqreturn_t usbin_uv_irq_handler(int irq, void *data);
455irqreturn_t usb_plugin_irq_handler(int irq, void *data);
456irqreturn_t usb_source_change_irq_handler(int irq, void *data);
457irqreturn_t icl_change_irq_handler(int irq, void *data);
458irqreturn_t typec_state_change_irq_handler(int irq, void *data);
Harry Yang6afaea22018-03-26 19:11:07 -0700459irqreturn_t typec_attach_detach_irq_handler(int irq, void *data);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800460irqreturn_t dc_plugin_irq_handler(int irq, void *data);
461irqreturn_t high_duty_cycle_irq_handler(int irq, void *data);
462irqreturn_t switcher_power_ok_irq_handler(int irq, void *data);
463irqreturn_t wdog_bark_irq_handler(int irq, void *data);
Ashay Jaiswala9e10912018-02-02 14:03:35 +0530464irqreturn_t typec_or_rid_detection_change_irq_handler(int irq, void *data);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800465
466int smblib_get_prop_input_suspend(struct smb_charger *chg,
467 union power_supply_propval *val);
468int smblib_get_prop_batt_present(struct smb_charger *chg,
469 union power_supply_propval *val);
470int smblib_get_prop_batt_capacity(struct smb_charger *chg,
471 union power_supply_propval *val);
472int smblib_get_prop_batt_status(struct smb_charger *chg,
473 union power_supply_propval *val);
474int smblib_get_prop_batt_charge_type(struct smb_charger *chg,
475 union power_supply_propval *val);
476int smblib_get_prop_batt_charge_done(struct smb_charger *chg,
477 union power_supply_propval *val);
478int smblib_get_prop_batt_health(struct smb_charger *chg,
479 union power_supply_propval *val);
480int smblib_get_prop_system_temp_level(struct smb_charger *chg,
481 union power_supply_propval *val);
482int smblib_get_prop_system_temp_level_max(struct smb_charger *chg,
483 union power_supply_propval *val);
484int smblib_get_prop_input_current_limited(struct smb_charger *chg,
485 union power_supply_propval *val);
486int smblib_get_prop_batt_voltage_now(struct smb_charger *chg,
487 union power_supply_propval *val);
488int smblib_get_prop_batt_current_now(struct smb_charger *chg,
489 union power_supply_propval *val);
490int smblib_get_prop_batt_temp(struct smb_charger *chg,
491 union power_supply_propval *val);
492int smblib_get_prop_batt_charge_counter(struct smb_charger *chg,
493 union power_supply_propval *val);
Subbaraman Narayanamurthyc4feb892018-05-07 18:43:45 -0700494int smblib_get_prop_batt_cycle_count(struct smb_charger *chg,
495 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800496int smblib_set_prop_input_suspend(struct smb_charger *chg,
497 const union power_supply_propval *val);
498int smblib_set_prop_batt_capacity(struct smb_charger *chg,
499 const union power_supply_propval *val);
500int smblib_set_prop_batt_status(struct smb_charger *chg,
501 const union power_supply_propval *val);
502int smblib_set_prop_system_temp_level(struct smb_charger *chg,
503 const union power_supply_propval *val);
504int smblib_set_prop_input_current_limited(struct smb_charger *chg,
505 const union power_supply_propval *val);
506
507int smblib_get_prop_dc_present(struct smb_charger *chg,
508 union power_supply_propval *val);
509int smblib_get_prop_dc_online(struct smb_charger *chg,
510 union power_supply_propval *val);
511int smblib_get_prop_dc_current_max(struct smb_charger *chg,
512 union power_supply_propval *val);
513int smblib_set_prop_dc_current_max(struct smb_charger *chg,
514 const union power_supply_propval *val);
515int smblib_get_prop_usb_present(struct smb_charger *chg,
516 union power_supply_propval *val);
517int smblib_get_prop_usb_online(struct smb_charger *chg,
518 union power_supply_propval *val);
519int smblib_get_prop_usb_suspend(struct smb_charger *chg,
520 union power_supply_propval *val);
521int smblib_get_prop_usb_voltage_max(struct smb_charger *chg,
522 union power_supply_propval *val);
Umang Agrawal9fb865a2018-06-25 16:24:00 +0530523int smblib_get_prop_usb_voltage_max_design(struct smb_charger *chg,
524 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800525int smblib_get_prop_typec_cc_orientation(struct smb_charger *chg,
526 union power_supply_propval *val);
527int smblib_get_prop_typec_power_role(struct smb_charger *chg,
528 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800529int smblib_get_prop_input_current_settled(struct smb_charger *chg,
530 union power_supply_propval *val);
531int smblib_get_prop_input_voltage_settled(struct smb_charger *chg,
532 union power_supply_propval *val);
533int smblib_get_prop_pd_in_hard_reset(struct smb_charger *chg,
534 union power_supply_propval *val);
535int smblib_get_pe_start(struct smb_charger *chg,
536 union power_supply_propval *val);
537int smblib_get_prop_die_health(struct smb_charger *chg,
538 union power_supply_propval *val);
539int smblib_set_prop_pd_current_max(struct smb_charger *chg,
540 const union power_supply_propval *val);
541int smblib_set_prop_sdp_current_max(struct smb_charger *chg,
542 const union power_supply_propval *val);
543int smblib_set_prop_pd_voltage_max(struct smb_charger *chg,
544 const union power_supply_propval *val);
545int smblib_set_prop_pd_voltage_min(struct smb_charger *chg,
546 const union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800547int smblib_set_prop_typec_power_role(struct smb_charger *chg,
548 const union power_supply_propval *val);
549int smblib_set_prop_pd_active(struct smb_charger *chg,
550 const union power_supply_propval *val);
551int smblib_set_prop_pd_in_hard_reset(struct smb_charger *chg,
552 const union power_supply_propval *val);
553int smblib_set_prop_ship_mode(struct smb_charger *chg,
554 const union power_supply_propval *val);
555void smblib_suspend_on_debug_battery(struct smb_charger *chg);
556int smblib_rerun_apsd_if_required(struct smb_charger *chg);
557int smblib_get_prop_fcc_delta(struct smb_charger *chg,
558 union power_supply_propval *val);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800559int smblib_dp_dm(struct smb_charger *chg, int val);
560int smblib_disable_hw_jeita(struct smb_charger *chg, bool disable);
Ashay Jaiswale0b3c472018-06-20 23:39:41 +0530561int smblib_run_aicl(struct smb_charger *chg, int type);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800562int smblib_set_icl_current(struct smb_charger *chg, int icl_ua);
563int smblib_get_icl_current(struct smb_charger *chg, int *icl_ua);
564int smblib_get_charge_current(struct smb_charger *chg, int *total_current_ua);
565int smblib_get_prop_pr_swap_in_progress(struct smb_charger *chg,
566 union power_supply_propval *val);
567int smblib_set_prop_pr_swap_in_progress(struct smb_charger *chg,
568 const union power_supply_propval *val);
569int smblib_stat_sw_override_cfg(struct smb_charger *chg, bool override);
Ashay Jaiswala55b7ed2018-03-23 17:23:48 +0530570int smblib_configure_wdog(struct smb_charger *chg, bool enable);
Ashay Jaiswal4d334f42018-04-25 10:58:49 +0530571int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val);
Ashay Jaiswalc96380de2018-05-16 12:02:36 +0530572int smblib_configure_hvdcp_apsd(struct smb_charger *chg, bool enable);
Ashay Jaiswalcbdf2e82018-05-27 23:59:01 +0530573int smblib_icl_override(struct smb_charger *chg, bool override);
Harry Yang4b7db0f2017-11-27 10:50:44 -0800574
575int smblib_init(struct smb_charger *chg);
576int smblib_deinit(struct smb_charger *chg);
577#endif /* __SMB5_CHARGER_H */