Loading Documentation/devicetree/bindings/power/smb1360-charger-fg.txt +5 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,9 @@ Optional Properties: thermistor inside the battery. This value is 16-bit float encoded value determined from the NTC-c1_coeff mapping. - qcom,otg-batt-curr-limit This property defines the current threshold draw from battery when device working at OTG mode. The possible values are: 350, 550, 950, 1500mA. Example: i2c@f9967000 { Loading Loading @@ -133,5 +136,7 @@ Example: qcom,fg-soc-max = <85>; qcom,fg-soc-min = <15>; qcom,thermal-mitigation = <1500 700 300 0>; qcom,otg-batt-curr-limit = <950>; }; }; drivers/power/smb1360-charger-fg.c +26 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ #define CHG_ITERM_200MA 0x7 #define RECHG_MV_MASK SMB1360_MASK(6, 5) #define RECHG_MV_SHIFT 5 #define OTG_CURRENT_MASK SMB1360_MASK(4, 3) #define OTG_CURRENT_SHIFT 3 #define CFG_BATT_CHG_ICL_REG 0x05 #define AC_INPUT_ICL_PIN_BIT BIT(7) Loading Loading @@ -240,6 +242,8 @@ enum { BATTERY_PROFILE_MAX, }; static int otg_curr_ma[] = {350, 550, 950, 1500}; struct smb1360_otg_regulator { struct regulator_desc rdesc; struct regulator_dev *rdev; Loading Loading @@ -269,6 +273,7 @@ struct smb1360_chip { unsigned int thermal_levels; unsigned int therm_lvl_sel; unsigned int *thermal_mitigation; int otg_batt_curr_limit; /* configuration data - fg */ int soc_max; Loading Loading @@ -2988,6 +2993,22 @@ static int smb1360_hw_init(struct smb1360_chip *chip) } } /* USB OTG current limit configuration */ if (chip->otg_batt_curr_limit != -EINVAL) { for (i = 0; i < ARRAY_SIZE(otg_curr_ma); i++) { if (otg_curr_ma[i] >= chip->otg_batt_curr_limit) break; } if (i == ARRAY_SIZE(otg_curr_ma)) i = i - 1; rc = smb1360_masked_write(chip, CFG_BATT_CHG_REG, OTG_CURRENT_MASK, i << OTG_CURRENT_SHIFT); if (rc) pr_err("Couldn't set OTG current limit, rc = %d\n", rc); } rc = smb1360_fg_config(chip); if (rc < 0) { Loading Loading @@ -3218,6 +3239,11 @@ static int smb_parse_dt(struct smb1360_chip *chip) if (rc < 0) chip->fg_cc_to_cv_mv = -EINVAL; rc = of_property_read_u32(node, "qcom,otg-batt-curr-limit", &chip->otg_batt_curr_limit); if (rc < 0) chip->otg_batt_curr_limit = -EINVAL; return 0; } Loading Loading
Documentation/devicetree/bindings/power/smb1360-charger-fg.txt +5 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,9 @@ Optional Properties: thermistor inside the battery. This value is 16-bit float encoded value determined from the NTC-c1_coeff mapping. - qcom,otg-batt-curr-limit This property defines the current threshold draw from battery when device working at OTG mode. The possible values are: 350, 550, 950, 1500mA. Example: i2c@f9967000 { Loading Loading @@ -133,5 +136,7 @@ Example: qcom,fg-soc-max = <85>; qcom,fg-soc-min = <15>; qcom,thermal-mitigation = <1500 700 300 0>; qcom,otg-batt-curr-limit = <950>; }; };
drivers/power/smb1360-charger-fg.c +26 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ #define CHG_ITERM_200MA 0x7 #define RECHG_MV_MASK SMB1360_MASK(6, 5) #define RECHG_MV_SHIFT 5 #define OTG_CURRENT_MASK SMB1360_MASK(4, 3) #define OTG_CURRENT_SHIFT 3 #define CFG_BATT_CHG_ICL_REG 0x05 #define AC_INPUT_ICL_PIN_BIT BIT(7) Loading Loading @@ -240,6 +242,8 @@ enum { BATTERY_PROFILE_MAX, }; static int otg_curr_ma[] = {350, 550, 950, 1500}; struct smb1360_otg_regulator { struct regulator_desc rdesc; struct regulator_dev *rdev; Loading Loading @@ -269,6 +273,7 @@ struct smb1360_chip { unsigned int thermal_levels; unsigned int therm_lvl_sel; unsigned int *thermal_mitigation; int otg_batt_curr_limit; /* configuration data - fg */ int soc_max; Loading Loading @@ -2988,6 +2993,22 @@ static int smb1360_hw_init(struct smb1360_chip *chip) } } /* USB OTG current limit configuration */ if (chip->otg_batt_curr_limit != -EINVAL) { for (i = 0; i < ARRAY_SIZE(otg_curr_ma); i++) { if (otg_curr_ma[i] >= chip->otg_batt_curr_limit) break; } if (i == ARRAY_SIZE(otg_curr_ma)) i = i - 1; rc = smb1360_masked_write(chip, CFG_BATT_CHG_REG, OTG_CURRENT_MASK, i << OTG_CURRENT_SHIFT); if (rc) pr_err("Couldn't set OTG current limit, rc = %d\n", rc); } rc = smb1360_fg_config(chip); if (rc < 0) { Loading Loading @@ -3218,6 +3239,11 @@ static int smb_parse_dt(struct smb1360_chip *chip) if (rc < 0) chip->fg_cc_to_cv_mv = -EINVAL; rc = of_property_read_u32(node, "qcom,otg-batt-curr-limit", &chip->otg_batt_curr_limit); if (rc < 0) chip->otg_batt_curr_limit = -EINVAL; return 0; } Loading