power: supply: qti_battery_charger: Add config to match m81 module
Added cycle_count_diff from liuquin-t-oss Reverse engineered atest from zeus V816.0.2.0.ULBCNXM Change-Id: I213a758dba7322a75fd2f03272f2cec8d379ed33
This commit is contained in:
parent
4a72ab3175
commit
42b638f115
@ -879,6 +879,12 @@ config MI_WLS_REVERSE_CHG_ONLY
|
||||
help
|
||||
Say Y here to enable mi only reverse wls chg
|
||||
|
||||
config MI_CHARGER_M81
|
||||
tristate "match m81 charger properties"
|
||||
help
|
||||
Say Y here to enable xiaomi properties similar to
|
||||
qti_battery_charger_main_m81 module on stock
|
||||
|
||||
source "drivers/power/supply/qcom/Kconfig"
|
||||
|
||||
endif # POWER_SUPPLY
|
||||
|
@ -38,6 +38,7 @@ static int blank_state = 1, sec_blank_state = 1;
|
||||
ATOMIC_NOTIFIER_HEAD(pen_charge_state_notifier);
|
||||
ATOMIC_NOTIFIER_HEAD(current_battery_level_notifier);
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
SRCU_NOTIFIER_HEAD(charger_notifier);
|
||||
EXPORT_SYMBOL_GPL(charger_notifier);
|
||||
|
||||
@ -58,6 +59,7 @@ int charger_notifier_call_cnain(unsigned long event, int val)
|
||||
return srcu_notifier_call_chain(&charger_notifier, event, &val);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(charger_notifier_call_cnain);
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
static const int battery_prop_map[BATT_PROP_MAX] = {
|
||||
[BATT_STATUS] = POWER_SUPPLY_PROP_STATUS,
|
||||
@ -2612,6 +2614,7 @@ static void qti_battery_register_panel_sec_notifier_work(struct work_struct *wor
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
static int charger_notifier_event(struct notifier_block *notifier,
|
||||
unsigned long chg_event, void *val)
|
||||
{
|
||||
@ -2640,6 +2643,7 @@ static int charger_notifier_event(struct notifier_block *notifier,
|
||||
}
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
extern void generate_xm_charge_uvent(struct work_struct *work);
|
||||
extern void xm_charger_debug_info_print_work(struct work_struct *work);
|
||||
@ -2845,8 +2849,10 @@ static int battery_chg_probe(struct platform_device *pdev)
|
||||
schedule_delayed_work(&bcdev->batt_update_work, 0);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
bcdev->chg_nb.notifier_call = charger_notifier_event;
|
||||
charger_reg_notifier(&bcdev->chg_nb);
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
return 0;
|
||||
error:
|
||||
|
@ -158,11 +158,15 @@ enum xm_property_id {
|
||||
XM_PROP_VERIFY_DIGEST,
|
||||
XM_PROP_CONNECTOR_TEMP,
|
||||
XM_PROP_AUTHENTIC,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_BATTERY_ADAPT_POWER_MATCH,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
XM_PROP_CHIP_OK,
|
||||
XM_PROP_VBUS_DISABLE,
|
||||
XM_PROP_REAL_TYPE,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_THERMAL_BOARD_TEMP,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
/*used for pd authentic*/
|
||||
XM_PROP_VERIFY_PROCESS,
|
||||
XM_PROP_VDM_CMD_CHARGER_VERSION,
|
||||
@ -207,7 +211,7 @@ enum xm_property_id {
|
||||
XM_PROP_SLAVE_DIE_TEMPERATURE,
|
||||
XM_PROP_FG_RAW_SOC,
|
||||
/* wireless charge infor */
|
||||
XM_PROP_WLS_START,
|
||||
XM_PROP_WLS_START = 50,
|
||||
XM_PROP_TX_MACL,
|
||||
XM_PROP_TX_MACH,
|
||||
XM_PROP_PEN_MACL,
|
||||
@ -238,7 +242,9 @@ enum xm_property_id {
|
||||
XM_PROP_WLS_CAR_ADAPTER,
|
||||
XM_PROP_WLS_TX_SPEED,
|
||||
XM_PROP_WLS_FC_FLAG,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_WLS_END,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
/**********************/
|
||||
XM_PROP_SHUTDOWN_DELAY,
|
||||
XM_PROP_FAKE_TEMP,
|
||||
@ -248,17 +254,24 @@ enum xm_property_id {
|
||||
XM_PROP_THERMAL_TEMP,
|
||||
XM_PROP_FB_BLANK_STATE,
|
||||
XM_PROP_SMART_BATT,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_SMART_CHG,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
XM_PROP_SHIPMODE_COUNT_RESET,
|
||||
XM_PROP_SPORT_MODE,
|
||||
XM_PROP_BATT_CONNT_ONLINE,
|
||||
XM_PROP_FAKE_CYCLE,
|
||||
XM_PROP_FAKE_SOH,
|
||||
XM_PROP_DELTAFV,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_OTG_UI_SUPPORT,
|
||||
XM_PROP_CID_STATUS,
|
||||
XM_PROP_CC_TOGGLE,
|
||||
XM_PROP_HIFI_CONNECT,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
#ifdef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_CYCLE_COUNT_DIFF,
|
||||
#endif /* CONFIG_MI_CHARGER_M81 */
|
||||
/*********nvt fuelgauge feature*********/
|
||||
XM_PROP_NVTFG_MONITOR_ISC,
|
||||
XM_PROP_NVTFG_MONITOR_SOA,
|
||||
@ -337,6 +350,7 @@ enum xm_property_id {
|
||||
XM_PROP_FG2_GaugingStatus,
|
||||
XM_PROP_FG2_FullChargeFlag,
|
||||
XM_PROP_FG2_RSOC,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_FG2_OVER_PEAK_FLAG,
|
||||
XM_PROP_FG2_CURRENT_DEVIATION,
|
||||
XM_PROP_FG2_POWER_DEVIATION,
|
||||
@ -358,6 +372,7 @@ enum xm_property_id {
|
||||
XM_PROP_FG2_SET_LEARNING_POWER_B,
|
||||
XM_PROP_FG2_GET_LEARNING_POWER_B,
|
||||
XM_PROP_FG2_GET_LEARNING_POWER_DEV_B,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
XM_PROP_FG_VENDOR_ID,
|
||||
/*begin dual fuel high temperature intercept feature */
|
||||
XM_PROP_FG_VOLTAGE_MAX,
|
||||
@ -380,6 +395,9 @@ enum xm_property_id {
|
||||
XM_PROP_SERVER_RESULT,
|
||||
XM_PROP_ADSP_RESULT,
|
||||
#endif
|
||||
#ifdef CONFIG_MI_CHARGER_M81
|
||||
XM_PROP_ATEST,
|
||||
#endif /* CONFIG_MI_CHARGER_M81 */
|
||||
XM_PROP_LAST_NODE,
|
||||
XM_PROP_MAX,
|
||||
};
|
||||
@ -606,6 +624,8 @@ struct battery_chg_dev {
|
||||
bool error_prop;
|
||||
struct work_struct pen_notifier_work;
|
||||
struct work_struct current_battery_level_notifier_work;
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
int thermal_board_temp;
|
||||
struct notifier_block chg_nb;
|
||||
#endif /* !#ifndef CONFIG_MI_CHARGER_M81 */
|
||||
};
|
||||
|
@ -735,6 +735,7 @@ static ssize_t authentic_show(struct class *c,
|
||||
}
|
||||
static CLASS_ATTR_RW(authentic);
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
static ssize_t bap_match_store(struct class *c,
|
||||
struct class_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
@ -769,6 +770,7 @@ static ssize_t bap_match_show(struct class *c,
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", pst->prop[XM_PROP_BATTERY_ADAPT_POWER_MATCH]);
|
||||
}
|
||||
static CLASS_ATTR_RW(bap_match);
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
static ssize_t chip_ok_show(struct class *c,
|
||||
struct class_attribute *attr, char *buf)
|
||||
@ -1371,6 +1373,7 @@ static ssize_t smart_batt_show(struct class *c,
|
||||
}
|
||||
static CLASS_ATTR_RW(smart_batt);
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
static ssize_t smart_chg_store(struct class *c,
|
||||
struct class_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
@ -1406,6 +1409,7 @@ static ssize_t smart_chg_show(struct class *c,
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", pst->prop[XM_PROP_SMART_CHG]);
|
||||
}
|
||||
static CLASS_ATTR_RW(smart_chg);
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
#define BSWAP_32(x) \
|
||||
(u32)((((u32)(x) & 0xff000000) >> 24) | \
|
||||
@ -2429,6 +2433,7 @@ static ssize_t deltafv_show(struct class *c,
|
||||
}
|
||||
static CLASS_ATTR_RO(deltafv);
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
static ssize_t otg_ui_support_show(struct class *c,
|
||||
struct class_attribute *attr, char *buf)
|
||||
{
|
||||
@ -2532,6 +2537,25 @@ static ssize_t hifi_connect_show(struct class *c,
|
||||
return scnprintf(buf, PAGE_SIZE, "%u", pst->prop[XM_PROP_HIFI_CONNECT]);
|
||||
}
|
||||
static CLASS_ATTR_RW(hifi_connect);
|
||||
#endif /* CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
#ifdef CONFIG_MI_CHARGER_M81
|
||||
static ssize_t cycle_count_diff_show(struct class *c,
|
||||
struct class_attribute *attr, char *buf)
|
||||
{
|
||||
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
|
||||
battery_class);
|
||||
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
|
||||
int rc;
|
||||
|
||||
rc = read_property_id(bcdev, pst, XM_PROP_CYCLE_COUNT_DIFF);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n", pst->prop[XM_PROP_CYCLE_COUNT_DIFF]);
|
||||
}
|
||||
static CLASS_ATTR_RO(cycle_count_diff);
|
||||
#endif /* CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
static ssize_t fg1_fastcharge_show(struct class *c,
|
||||
struct class_attribute *attr, char *buf)
|
||||
@ -4595,6 +4619,43 @@ static ssize_t sport_mode_show(struct class *c,
|
||||
}
|
||||
static CLASS_ATTR_RW(sport_mode);
|
||||
|
||||
#ifdef CONFIG_MI_CHARGER_M81
|
||||
static ssize_t atest_store(struct class *c,
|
||||
struct class_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
|
||||
battery_class);
|
||||
int rc;
|
||||
int val;
|
||||
|
||||
if (kstrtoint(buf, 10, &val))
|
||||
return -EINVAL;
|
||||
|
||||
rc = write_property_id(bcdev, &bcdev->psy_list[PSY_TYPE_XM],
|
||||
XM_PROP_ATEST, val);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return count;
|
||||
}
|
||||
static ssize_t atest_show(struct class *c,
|
||||
struct class_attribute *attr, char *buf)
|
||||
{
|
||||
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
|
||||
battery_class);
|
||||
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
|
||||
int rc;
|
||||
|
||||
rc = read_property_id(bcdev, pst, XM_PROP_ATEST);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%u\n", pst->prop[XM_PROP_ATEST]);
|
||||
}
|
||||
static CLASS_ATTR_RW(atest);
|
||||
#endif /* #ifndef CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
static ssize_t last_node_show(struct class *c,
|
||||
struct class_attribute *attr, char *buf)
|
||||
{
|
||||
@ -4610,6 +4671,7 @@ static ssize_t last_node_show(struct class *c,
|
||||
}
|
||||
static CLASS_ATTR_RO(last_node);
|
||||
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
static ssize_t thermal_board_temp_store(struct class *c,
|
||||
struct class_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
@ -4646,6 +4708,7 @@ static ssize_t thermal_board_temp_show(struct class *c,
|
||||
return scnprintf(buf, PAGE_SIZE, "%u", bcdev->thermal_board_temp);
|
||||
}
|
||||
static CLASS_ATTR_RW(thermal_board_temp);
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
|
||||
static struct attribute *xiaomi_battery_class_attrs[] = {
|
||||
#ifndef CONFIG_MI_WLS_REVERSE_CHG_ONLY
|
||||
@ -4656,7 +4719,9 @@ static struct attribute *xiaomi_battery_class_attrs[] = {
|
||||
&class_attr_verify_digest.attr,
|
||||
&class_attr_connector_temp.attr,
|
||||
&class_attr_authentic.attr,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
&class_attr_bap_match.attr,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
&class_attr_chip_ok.attr,
|
||||
&class_attr_vbus_disable.attr,
|
||||
&class_attr_verify_process.attr,
|
||||
@ -4691,16 +4756,23 @@ static struct attribute *xiaomi_battery_class_attrs[] = {
|
||||
&class_attr_fake_cycle.attr,
|
||||
&class_attr_fake_soh.attr,
|
||||
&class_attr_deltafv.attr,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
&class_attr_otg_ui_support.attr,
|
||||
&class_attr_cid_status.attr,
|
||||
&class_attr_cc_toggle.attr,
|
||||
&class_attr_hifi_connect.attr,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
&class_attr_fake_temp.attr,
|
||||
#ifdef CONFIG_MI_CHARGER_M81
|
||||
&class_attr_cycle_count_diff.attr,
|
||||
#endif /* CONFIG_MI_CHARGER_M81 */
|
||||
&class_attr_thermal_remove.attr,
|
||||
&class_attr_typec_mode.attr,
|
||||
&class_attr_mtbf_current.attr,
|
||||
&class_attr_smart_batt.attr,
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
&class_attr_smart_chg.attr,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
&class_attr_shipmode_count_reset.attr,
|
||||
&class_attr_sport_mode.attr,
|
||||
&class_attr_apdo_max.attr,
|
||||
@ -4861,7 +4933,12 @@ static struct attribute *xiaomi_battery_class_attrs[] = {
|
||||
&class_attr_server_result.attr,
|
||||
&class_attr_adsp_result.attr,
|
||||
#endif
|
||||
#ifndef CONFIG_MI_CHARGER_M81
|
||||
&class_attr_thermal_board_temp.attr,
|
||||
#endif /* !CONFIG_MI_CHARGER_M81 */
|
||||
#ifdef CONFIG_MI_CHARGER_M81
|
||||
&class_attr_atest.attr,
|
||||
#endif /* CONFIG_MI_CHARGER_M81 */
|
||||
&class_attr_last_node.attr,
|
||||
NULL,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user