Loading drivers/power/qpnp-fg.c +18 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,7 @@ struct fg_chip { struct delayed_work update_sram_data; char *batt_profile; unsigned int batt_profile_len; const char *batt_type; }; /* FG_MEMIF DEBUGFS structures */ Loading @@ -237,6 +238,7 @@ struct fg_chip { static const char *DFS_ROOT_NAME = "fg_memif"; static const mode_t DFS_MODE = S_IRUSR | S_IWUSR; static const char *default_batt_type = "Unknown Battery"; /* Log buffer */ struct fg_log_buffer { Loading Loading @@ -934,6 +936,7 @@ static enum power_supply_property fg_power_props[] = { POWER_SUPPLY_PROP_WARM_TEMP, POWER_SUPPLY_PROP_RESISTANCE, POWER_SUPPLY_PROP_RESISTANCE_ID, POWER_SUPPLY_PROP_BATTERY_TYPE, }; static int fg_power_get_property(struct power_supply *psy, Loading @@ -943,6 +946,9 @@ static int fg_power_get_property(struct power_supply *psy, struct fg_chip *chip = container_of(psy, struct fg_chip, bms_psy); switch (psp) { case POWER_SUPPLY_PROP_BATTERY_TYPE: val->strval = chip->batt_type; break; case POWER_SUPPLY_PROP_CAPACITY: val->intval = get_prop_capacity(chip); break; Loading Loading @@ -1183,6 +1189,16 @@ wait: return 0; } chip->batt_profile = devm_kzalloc(chip->dev, sizeof(char) * len, GFP_KERNEL); rc = of_property_read_string(profile_node, "qcom,battery-type", &chip->batt_type); if (rc) { pr_err("Could not find battery data type: %d\n", rc); return 0; } chip->batt_profile = devm_kzalloc(chip->dev, sizeof(char) * len, GFP_KERNEL); if (!chip->batt_profile) Loading Loading @@ -1902,6 +1918,8 @@ static int fg_probe(struct spmi_device *spmi) goto of_init_fail; } chip->batt_type = default_batt_type; chip->bms_psy.name = "bms"; chip->bms_psy.type = POWER_SUPPLY_TYPE_BMS; chip->bms_psy.properties = fg_power_props; Loading drivers/power/qpnp-smbcharger.c +28 −1 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ struct smbchg_chip { bool soft_vfloat_comp_disabled; bool chg_enabled; bool low_icl_wa_on; bool battery_unknown; bool charge_unknown_battery; struct parallel_usb_cfg parallel; Loading Loading @@ -1300,17 +1301,44 @@ static int smbchg_dc_is_writeable(struct power_supply *psy, return rc; } #define USBIN_SUSPEND_SRC_BIT BIT(6) static void smbchg_unknown_battery_en(struct smbchg_chip *chip, bool en) { int rc; if (en == chip->battery_unknown || chip->charge_unknown_battery) return; chip->battery_unknown = en; rc = smbchg_sec_masked_write(chip, chip->usb_chgpth_base + CHGPTH_CFG, USBIN_SUSPEND_SRC_BIT, en ? 0 : USBIN_SUSPEND_SRC_BIT); if (rc < 0) { dev_err(chip->dev, "Couldn't set usb_chgpth cfg rc=%d\n", rc); return; } } #define UNKNOWN_BATT_TYPE "Unknown Battery" static void smbchg_external_power_changed(struct power_supply *psy) { struct smbchg_chip *chip = container_of(psy, struct smbchg_chip, batt_psy); union power_supply_propval prop = {0,}; int rc, current_limit = 0; bool en; if (chip->bms_psy_name) chip->bms_psy = power_supply_get_by_name((char *)chip->bms_psy_name); if (chip->bms_psy) { chip->bms_psy->get_property(chip->bms_psy, POWER_SUPPLY_PROP_BATTERY_TYPE, &prop); en = strcmp(prop.strval, UNKNOWN_BATT_TYPE) != 0; smbchg_unknown_battery_en(chip, en); } rc = chip->usb_psy->get_property(chip->usb_psy, POWER_SUPPLY_PROP_CHARGING_ENABLED, &prop); if (rc < 0) Loading Loading @@ -2018,7 +2046,6 @@ static inline int get_bpd(const char *name) #define CHG_ITERM_500MA 0x6 #define CHG_ITERM_600MA 0x7 #define CHG_ITERM_MASK SMB_MASK(2, 0) #define USBIN_SUSPEND_SRC_BIT BIT(6) #define USB51_COMMAND_POL BIT(2) #define USB51AC_CTRL BIT(1) #define SFT_CFG 0xFD Loading Loading
drivers/power/qpnp-fg.c +18 −0 Original line number Diff line number Diff line Loading @@ -226,6 +226,7 @@ struct fg_chip { struct delayed_work update_sram_data; char *batt_profile; unsigned int batt_profile_len; const char *batt_type; }; /* FG_MEMIF DEBUGFS structures */ Loading @@ -237,6 +238,7 @@ struct fg_chip { static const char *DFS_ROOT_NAME = "fg_memif"; static const mode_t DFS_MODE = S_IRUSR | S_IWUSR; static const char *default_batt_type = "Unknown Battery"; /* Log buffer */ struct fg_log_buffer { Loading Loading @@ -934,6 +936,7 @@ static enum power_supply_property fg_power_props[] = { POWER_SUPPLY_PROP_WARM_TEMP, POWER_SUPPLY_PROP_RESISTANCE, POWER_SUPPLY_PROP_RESISTANCE_ID, POWER_SUPPLY_PROP_BATTERY_TYPE, }; static int fg_power_get_property(struct power_supply *psy, Loading @@ -943,6 +946,9 @@ static int fg_power_get_property(struct power_supply *psy, struct fg_chip *chip = container_of(psy, struct fg_chip, bms_psy); switch (psp) { case POWER_SUPPLY_PROP_BATTERY_TYPE: val->strval = chip->batt_type; break; case POWER_SUPPLY_PROP_CAPACITY: val->intval = get_prop_capacity(chip); break; Loading Loading @@ -1183,6 +1189,16 @@ wait: return 0; } chip->batt_profile = devm_kzalloc(chip->dev, sizeof(char) * len, GFP_KERNEL); rc = of_property_read_string(profile_node, "qcom,battery-type", &chip->batt_type); if (rc) { pr_err("Could not find battery data type: %d\n", rc); return 0; } chip->batt_profile = devm_kzalloc(chip->dev, sizeof(char) * len, GFP_KERNEL); if (!chip->batt_profile) Loading Loading @@ -1902,6 +1918,8 @@ static int fg_probe(struct spmi_device *spmi) goto of_init_fail; } chip->batt_type = default_batt_type; chip->bms_psy.name = "bms"; chip->bms_psy.type = POWER_SUPPLY_TYPE_BMS; chip->bms_psy.properties = fg_power_props; Loading
drivers/power/qpnp-smbcharger.c +28 −1 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ struct smbchg_chip { bool soft_vfloat_comp_disabled; bool chg_enabled; bool low_icl_wa_on; bool battery_unknown; bool charge_unknown_battery; struct parallel_usb_cfg parallel; Loading Loading @@ -1300,17 +1301,44 @@ static int smbchg_dc_is_writeable(struct power_supply *psy, return rc; } #define USBIN_SUSPEND_SRC_BIT BIT(6) static void smbchg_unknown_battery_en(struct smbchg_chip *chip, bool en) { int rc; if (en == chip->battery_unknown || chip->charge_unknown_battery) return; chip->battery_unknown = en; rc = smbchg_sec_masked_write(chip, chip->usb_chgpth_base + CHGPTH_CFG, USBIN_SUSPEND_SRC_BIT, en ? 0 : USBIN_SUSPEND_SRC_BIT); if (rc < 0) { dev_err(chip->dev, "Couldn't set usb_chgpth cfg rc=%d\n", rc); return; } } #define UNKNOWN_BATT_TYPE "Unknown Battery" static void smbchg_external_power_changed(struct power_supply *psy) { struct smbchg_chip *chip = container_of(psy, struct smbchg_chip, batt_psy); union power_supply_propval prop = {0,}; int rc, current_limit = 0; bool en; if (chip->bms_psy_name) chip->bms_psy = power_supply_get_by_name((char *)chip->bms_psy_name); if (chip->bms_psy) { chip->bms_psy->get_property(chip->bms_psy, POWER_SUPPLY_PROP_BATTERY_TYPE, &prop); en = strcmp(prop.strval, UNKNOWN_BATT_TYPE) != 0; smbchg_unknown_battery_en(chip, en); } rc = chip->usb_psy->get_property(chip->usb_psy, POWER_SUPPLY_PROP_CHARGING_ENABLED, &prop); if (rc < 0) Loading Loading @@ -2018,7 +2046,6 @@ static inline int get_bpd(const char *name) #define CHG_ITERM_500MA 0x6 #define CHG_ITERM_600MA 0x7 #define CHG_ITERM_MASK SMB_MASK(2, 0) #define USBIN_SUSPEND_SRC_BIT BIT(6) #define USB51_COMMAND_POL BIT(2) #define USB51AC_CTRL BIT(1) #define SFT_CFG 0xFD Loading