Loading drivers/power/supply/qcom/qpnp-smb5.c +13 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,7 @@ static enum power_supply_property smb5_usb_props[] = { POWER_SUPPLY_PROP_PD_VOLTAGE_MIN, POWER_SUPPLY_PROP_SDP_CURRENT_MAX, POWER_SUPPLY_PROP_CONNECTOR_TYPE, POWER_SUPPLY_PROP_CONNECTOR_HEALTH, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_SMB_EN_MODE, POWER_SUPPLY_PROP_SCOPE, Loading Loading @@ -594,6 +595,12 @@ static int smb5_usb_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_CONNECTOR_TYPE: val->intval = chg->connector_type; break; case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: if (chg->connector_health == -EINVAL) rc = smblib_get_prop_connector_health(chg, val); else val->intval = chg->connector_health; break; case POWER_SUPPLY_PROP_SCOPE: val->intval = POWER_SUPPLY_SCOPE_UNKNOWN; rc = smblib_get_prop_usb_present(chg, &pval); Loading Loading @@ -663,6 +670,10 @@ static int smb5_usb_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_SDP_CURRENT_MAX: rc = smblib_set_prop_sdp_current_max(chg, val); break; case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: chg->connector_health = val->intval; power_supply_changed(chg->usb_psy); break; default: pr_err("set prop %d is not supported\n", psp); rc = -EINVAL; Loading @@ -677,6 +688,7 @@ static int smb5_usb_prop_is_writeable(struct power_supply *psy, { switch (psp) { case POWER_SUPPLY_PROP_CTM_CURRENT_MAX: case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: return 1; default: break; Loading Loading @@ -2398,6 +2410,7 @@ static int smb5_probe(struct platform_device *pdev) chg->mode = PARALLEL_MASTER; chg->irq_info = smb5_irqs; chg->die_health = -EINVAL; chg->connector_health = -EINVAL; chg->otg_present = false; chg->regmap = dev_get_regmap(chg->dev->parent, NULL); Loading drivers/power/supply/qcom/smb5-lib.c +34 −0 Original line number Diff line number Diff line Loading @@ -2245,6 +2245,40 @@ int smblib_get_prop_die_health(struct smb_charger *chg, return 0; } int smblib_get_prop_connector_health(struct smb_charger *chg, union power_supply_propval *val) { int rc; u8 stat; rc = smblib_read(chg, CONNECTOR_TEMP_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, "Couldn't read CONNECTOR_TEMP_STATUS_REG, rc=%d\n", rc); return rc; } /* Thermal status bits are mutually exclusive */ switch (stat) { case CONNECTOR_TEMP_LB_BIT: val->intval = POWER_SUPPLY_HEALTH_COOL; break; case CONNECTOR_TEMP_UB_BIT: val->intval = POWER_SUPPLY_HEALTH_WARM; break; case CONNECTOR_TEMP_RST_BIT: val->intval = POWER_SUPPLY_HEALTH_HOT; break; case CONNECTOR_TEMP_SHDN_BIT: val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; break; default: val->intval = POWER_SUPPLY_HEALTH_UNKNOWN; } return 0; } #define SDP_CURRENT_UA 500000 #define CDP_CURRENT_UA 1500000 #define DCP_CURRENT_UA 1500000 Loading drivers/power/supply/qcom/smb5-lib.h +3 −0 Original line number Diff line number Diff line Loading @@ -376,6 +376,7 @@ struct smb_charger { int pulse_cnt; int die_health; int connector_health; /* flash */ u32 flash_derating_soc; Loading Loading @@ -514,6 +515,8 @@ int smblib_get_prop_charger_temp(struct smb_charger *chg, union power_supply_propval *val); int smblib_get_prop_die_health(struct smb_charger *chg, union power_supply_propval *val); int smblib_get_prop_connector_health(struct smb_charger *chg, union power_supply_propval *val); int smblib_set_prop_pd_current_max(struct smb_charger *chg, const union power_supply_propval *val); int smblib_set_prop_sdp_current_max(struct smb_charger *chg, Loading drivers/power/supply/qcom/smb5-reg.h +6 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,12 @@ enum { #define TEMP_BELOW_RANGE_BIT BIT(1) #define THERMREG_DISABLED_BIT BIT(0) #define CONNECTOR_TEMP_STATUS_REG (MISC_BASE + 0x09) #define CONNECTOR_TEMP_SHDN_BIT BIT(3) #define CONNECTOR_TEMP_RST_BIT BIT(2) #define CONNECTOR_TEMP_UB_BIT BIT(1) #define CONNECTOR_TEMP_LB_BIT BIT(0) #define BARK_BITE_WDOG_PET_REG (MISC_BASE + 0x43) #define BARK_BITE_WDOG_PET_BIT BIT(0) Loading Loading
drivers/power/supply/qcom/qpnp-smb5.c +13 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,7 @@ static enum power_supply_property smb5_usb_props[] = { POWER_SUPPLY_PROP_PD_VOLTAGE_MIN, POWER_SUPPLY_PROP_SDP_CURRENT_MAX, POWER_SUPPLY_PROP_CONNECTOR_TYPE, POWER_SUPPLY_PROP_CONNECTOR_HEALTH, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_SMB_EN_MODE, POWER_SUPPLY_PROP_SCOPE, Loading Loading @@ -594,6 +595,12 @@ static int smb5_usb_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_CONNECTOR_TYPE: val->intval = chg->connector_type; break; case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: if (chg->connector_health == -EINVAL) rc = smblib_get_prop_connector_health(chg, val); else val->intval = chg->connector_health; break; case POWER_SUPPLY_PROP_SCOPE: val->intval = POWER_SUPPLY_SCOPE_UNKNOWN; rc = smblib_get_prop_usb_present(chg, &pval); Loading Loading @@ -663,6 +670,10 @@ static int smb5_usb_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_SDP_CURRENT_MAX: rc = smblib_set_prop_sdp_current_max(chg, val); break; case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: chg->connector_health = val->intval; power_supply_changed(chg->usb_psy); break; default: pr_err("set prop %d is not supported\n", psp); rc = -EINVAL; Loading @@ -677,6 +688,7 @@ static int smb5_usb_prop_is_writeable(struct power_supply *psy, { switch (psp) { case POWER_SUPPLY_PROP_CTM_CURRENT_MAX: case POWER_SUPPLY_PROP_CONNECTOR_HEALTH: return 1; default: break; Loading Loading @@ -2398,6 +2410,7 @@ static int smb5_probe(struct platform_device *pdev) chg->mode = PARALLEL_MASTER; chg->irq_info = smb5_irqs; chg->die_health = -EINVAL; chg->connector_health = -EINVAL; chg->otg_present = false; chg->regmap = dev_get_regmap(chg->dev->parent, NULL); Loading
drivers/power/supply/qcom/smb5-lib.c +34 −0 Original line number Diff line number Diff line Loading @@ -2245,6 +2245,40 @@ int smblib_get_prop_die_health(struct smb_charger *chg, return 0; } int smblib_get_prop_connector_health(struct smb_charger *chg, union power_supply_propval *val) { int rc; u8 stat; rc = smblib_read(chg, CONNECTOR_TEMP_STATUS_REG, &stat); if (rc < 0) { smblib_err(chg, "Couldn't read CONNECTOR_TEMP_STATUS_REG, rc=%d\n", rc); return rc; } /* Thermal status bits are mutually exclusive */ switch (stat) { case CONNECTOR_TEMP_LB_BIT: val->intval = POWER_SUPPLY_HEALTH_COOL; break; case CONNECTOR_TEMP_UB_BIT: val->intval = POWER_SUPPLY_HEALTH_WARM; break; case CONNECTOR_TEMP_RST_BIT: val->intval = POWER_SUPPLY_HEALTH_HOT; break; case CONNECTOR_TEMP_SHDN_BIT: val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; break; default: val->intval = POWER_SUPPLY_HEALTH_UNKNOWN; } return 0; } #define SDP_CURRENT_UA 500000 #define CDP_CURRENT_UA 1500000 #define DCP_CURRENT_UA 1500000 Loading
drivers/power/supply/qcom/smb5-lib.h +3 −0 Original line number Diff line number Diff line Loading @@ -376,6 +376,7 @@ struct smb_charger { int pulse_cnt; int die_health; int connector_health; /* flash */ u32 flash_derating_soc; Loading Loading @@ -514,6 +515,8 @@ int smblib_get_prop_charger_temp(struct smb_charger *chg, union power_supply_propval *val); int smblib_get_prop_die_health(struct smb_charger *chg, union power_supply_propval *val); int smblib_get_prop_connector_health(struct smb_charger *chg, union power_supply_propval *val); int smblib_set_prop_pd_current_max(struct smb_charger *chg, const union power_supply_propval *val); int smblib_set_prop_sdp_current_max(struct smb_charger *chg, Loading
drivers/power/supply/qcom/smb5-reg.h +6 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,12 @@ enum { #define TEMP_BELOW_RANGE_BIT BIT(1) #define THERMREG_DISABLED_BIT BIT(0) #define CONNECTOR_TEMP_STATUS_REG (MISC_BASE + 0x09) #define CONNECTOR_TEMP_SHDN_BIT BIT(3) #define CONNECTOR_TEMP_RST_BIT BIT(2) #define CONNECTOR_TEMP_UB_BIT BIT(1) #define CONNECTOR_TEMP_LB_BIT BIT(0) #define BARK_BITE_WDOG_PET_REG (MISC_BASE + 0x43) #define BARK_BITE_WDOG_PET_BIT BIT(0) Loading