Loading Documentation/devicetree/bindings/power/qpnp-charger.txt +2 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,8 @@ Parent node optional properties: that exhibit inaccuracies in battery current readings. This phandle is used to check the version of the PMIC and apply necessary software workarounds. - qcom,ext-ovp-present Indicates if an external OVP exists which reduces the overall input resistance of the charge path. Sub node required structure: - A qcom,chg node must be a child of an SPMI node that has specified Loading drivers/power/power_supply_sysfs.c +1 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,7 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(input_voltage_regulation), POWER_SUPPLY_ATTR(current_max), POWER_SUPPLY_ATTR(input_current_max), POWER_SUPPLY_ATTR(input_current_trim), POWER_SUPPLY_ATTR(current_now), POWER_SUPPLY_ATTR(current_avg), POWER_SUPPLY_ATTR(power_now), Loading drivers/power/qpnp-charger.c +63 −1 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ #define CHGR_USB_USB_SUSP 0x47 #define CHGR_USB_USB_OTG_CTL 0x48 #define CHGR_USB_ENUM_T_STOP 0x4E #define CHGR_USB_TRIM 0xF1 #define CHGR_CHG_TEMP_THRESH 0x66 #define CHGR_BAT_IF_PRES_STATUS 0x08 #define CHGR_STATUS 0x09 Loading Loading @@ -680,6 +681,48 @@ qpnp_chg_idcmax_set(struct qpnp_chg_chip *chip, int mA) return rc; } static int qpnp_chg_iusb_trim_get(struct qpnp_chg_chip *chip) { int rc = 0; u8 trim_reg; rc = qpnp_chg_read(chip, &trim_reg, chip->usb_chgpth_base + CHGR_USB_TRIM, 1); if (rc) { pr_err("failed to read USB_TRIM rc=%d\n", rc); return 0; } return trim_reg; } static int qpnp_chg_iusb_trim_set(struct qpnp_chg_chip *chip, int trim) { int rc = 0; rc = qpnp_chg_masked_write(chip, chip->usb_chgpth_base + SEC_ACCESS, 0xFF, 0xA5, 1); if (rc) { pr_err("failed to write SEC_ACCESS rc=%d\n", rc); return rc; } rc = qpnp_chg_masked_write(chip, chip->usb_chgpth_base + CHGR_USB_TRIM, 0xFF, trim, 1); if (rc) { pr_err("failed to write USB TRIM rc=%d\n", rc); return rc; } return rc; } static int qpnp_chg_iusbmax_set(struct qpnp_chg_chip *chip, int mA) { Loading Loading @@ -1364,6 +1407,7 @@ qpnp_batt_property_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_CHARGING_ENABLED: case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL: case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX: case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: case POWER_SUPPLY_PROP_VOLTAGE_MIN: case POWER_SUPPLY_PROP_COOL_TEMP: case POWER_SUPPLY_PROP_WARM_TEMP: Loading Loading @@ -1476,6 +1520,7 @@ static enum power_supply_property msm_batt_power_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_INPUT_CURRENT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM, POWER_SUPPLY_PROP_VOLTAGE_MIN, POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, Loading @@ -1499,7 +1544,11 @@ static char *pm_batt_supplied_to[] = { static int charger_monitor; module_param(charger_monitor, int, 0644); static int ext_ovp_present; module_param(ext_ovp_present, int, 0444); #define USB_WALL_THRESHOLD_MA 500 #define OVP_USB_WALL_THRESHOLD_MA 200 static int qpnp_power_get_property_mains(struct power_supply *psy, enum power_supply_property psp, Loading Loading @@ -1837,8 +1886,12 @@ qpnp_batt_external_power_changed(struct power_supply *psy) if (((ret.intval / 1000) > USB_WALL_THRESHOLD_MA) && (charger_monitor || !chip->charger_monitor_checked)) { if (!ext_ovp_present) qpnp_chg_iusbmax_set(chip, USB_WALL_THRESHOLD_MA); else qpnp_chg_iusbmax_set(chip, OVP_USB_WALL_THRESHOLD_MA); } else { qpnp_chg_iusbmax_set(chip, ret.intval / 1000); } Loading Loading @@ -1933,6 +1986,9 @@ qpnp_batt_power_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX: val->intval = qpnp_chg_usb_iusbmax_get(chip) * 1000; break; case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: val->intval = qpnp_chg_iusb_trim_get(chip); break; case POWER_SUPPLY_PROP_VOLTAGE_MIN: val->intval = qpnp_chg_vinmin_get(chip) * 1000; break; Loading Loading @@ -3032,6 +3088,9 @@ qpnp_batt_power_set_property(struct power_supply *psy, case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX: qpnp_chg_iusbmax_set(chip, val->intval / 1000); break; case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: qpnp_chg_iusb_trim_set(chip, val->intval); break; case POWER_SUPPLY_PROP_VOLTAGE_MIN: qpnp_chg_vinmin_set(chip, val->intval / 1000); break; Loading Loading @@ -3744,6 +3803,9 @@ qpnp_charger_read_dt_props(struct qpnp_chg_chip *chip) chip->btc_disabled = of_property_read_bool(chip->spmi->dev.of_node, "qcom,btc-disabled"); ext_ovp_present = of_property_read_bool(chip->spmi->dev.of_node, "qcom,ext-ovp-present"); /* Get the charging-disabled property */ chip->charging_disabled = of_property_read_bool(chip->spmi->dev.of_node, "qcom,charging-disabled"); Loading include/linux/power_supply.h +1 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION, POWER_SUPPLY_PROP_CURRENT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_POWER_NOW, Loading Loading
Documentation/devicetree/bindings/power/qpnp-charger.txt +2 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,8 @@ Parent node optional properties: that exhibit inaccuracies in battery current readings. This phandle is used to check the version of the PMIC and apply necessary software workarounds. - qcom,ext-ovp-present Indicates if an external OVP exists which reduces the overall input resistance of the charge path. Sub node required structure: - A qcom,chg node must be a child of an SPMI node that has specified Loading
drivers/power/power_supply_sysfs.c +1 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,7 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(input_voltage_regulation), POWER_SUPPLY_ATTR(current_max), POWER_SUPPLY_ATTR(input_current_max), POWER_SUPPLY_ATTR(input_current_trim), POWER_SUPPLY_ATTR(current_now), POWER_SUPPLY_ATTR(current_avg), POWER_SUPPLY_ATTR(power_now), Loading
drivers/power/qpnp-charger.c +63 −1 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ #define CHGR_USB_USB_SUSP 0x47 #define CHGR_USB_USB_OTG_CTL 0x48 #define CHGR_USB_ENUM_T_STOP 0x4E #define CHGR_USB_TRIM 0xF1 #define CHGR_CHG_TEMP_THRESH 0x66 #define CHGR_BAT_IF_PRES_STATUS 0x08 #define CHGR_STATUS 0x09 Loading Loading @@ -680,6 +681,48 @@ qpnp_chg_idcmax_set(struct qpnp_chg_chip *chip, int mA) return rc; } static int qpnp_chg_iusb_trim_get(struct qpnp_chg_chip *chip) { int rc = 0; u8 trim_reg; rc = qpnp_chg_read(chip, &trim_reg, chip->usb_chgpth_base + CHGR_USB_TRIM, 1); if (rc) { pr_err("failed to read USB_TRIM rc=%d\n", rc); return 0; } return trim_reg; } static int qpnp_chg_iusb_trim_set(struct qpnp_chg_chip *chip, int trim) { int rc = 0; rc = qpnp_chg_masked_write(chip, chip->usb_chgpth_base + SEC_ACCESS, 0xFF, 0xA5, 1); if (rc) { pr_err("failed to write SEC_ACCESS rc=%d\n", rc); return rc; } rc = qpnp_chg_masked_write(chip, chip->usb_chgpth_base + CHGR_USB_TRIM, 0xFF, trim, 1); if (rc) { pr_err("failed to write USB TRIM rc=%d\n", rc); return rc; } return rc; } static int qpnp_chg_iusbmax_set(struct qpnp_chg_chip *chip, int mA) { Loading Loading @@ -1364,6 +1407,7 @@ qpnp_batt_property_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_CHARGING_ENABLED: case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL: case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX: case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: case POWER_SUPPLY_PROP_VOLTAGE_MIN: case POWER_SUPPLY_PROP_COOL_TEMP: case POWER_SUPPLY_PROP_WARM_TEMP: Loading Loading @@ -1476,6 +1520,7 @@ static enum power_supply_property msm_batt_power_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_INPUT_CURRENT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM, POWER_SUPPLY_PROP_VOLTAGE_MIN, POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION, POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, Loading @@ -1499,7 +1544,11 @@ static char *pm_batt_supplied_to[] = { static int charger_monitor; module_param(charger_monitor, int, 0644); static int ext_ovp_present; module_param(ext_ovp_present, int, 0444); #define USB_WALL_THRESHOLD_MA 500 #define OVP_USB_WALL_THRESHOLD_MA 200 static int qpnp_power_get_property_mains(struct power_supply *psy, enum power_supply_property psp, Loading Loading @@ -1837,8 +1886,12 @@ qpnp_batt_external_power_changed(struct power_supply *psy) if (((ret.intval / 1000) > USB_WALL_THRESHOLD_MA) && (charger_monitor || !chip->charger_monitor_checked)) { if (!ext_ovp_present) qpnp_chg_iusbmax_set(chip, USB_WALL_THRESHOLD_MA); else qpnp_chg_iusbmax_set(chip, OVP_USB_WALL_THRESHOLD_MA); } else { qpnp_chg_iusbmax_set(chip, ret.intval / 1000); } Loading Loading @@ -1933,6 +1986,9 @@ qpnp_batt_power_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX: val->intval = qpnp_chg_usb_iusbmax_get(chip) * 1000; break; case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: val->intval = qpnp_chg_iusb_trim_get(chip); break; case POWER_SUPPLY_PROP_VOLTAGE_MIN: val->intval = qpnp_chg_vinmin_get(chip) * 1000; break; Loading Loading @@ -3032,6 +3088,9 @@ qpnp_batt_power_set_property(struct power_supply *psy, case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX: qpnp_chg_iusbmax_set(chip, val->intval / 1000); break; case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM: qpnp_chg_iusb_trim_set(chip, val->intval); break; case POWER_SUPPLY_PROP_VOLTAGE_MIN: qpnp_chg_vinmin_set(chip, val->intval / 1000); break; Loading Loading @@ -3744,6 +3803,9 @@ qpnp_charger_read_dt_props(struct qpnp_chg_chip *chip) chip->btc_disabled = of_property_read_bool(chip->spmi->dev.of_node, "qcom,btc-disabled"); ext_ovp_present = of_property_read_bool(chip->spmi->dev.of_node, "qcom,ext-ovp-present"); /* Get the charging-disabled property */ chip->charging_disabled = of_property_read_bool(chip->spmi->dev.of_node, "qcom,charging-disabled"); Loading
include/linux/power_supply.h +1 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION, POWER_SUPPLY_PROP_CURRENT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_POWER_NOW, Loading