Loading drivers/power/supply/power_supply_sysfs.c +1 −0 Original line number Original line Diff line number Diff line Loading @@ -388,6 +388,7 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(toggle_stat), POWER_SUPPLY_ATTR(toggle_stat), POWER_SUPPLY_ATTR(main_fcc_max), POWER_SUPPLY_ATTR(main_fcc_max), POWER_SUPPLY_ATTR(fg_reset), POWER_SUPPLY_ATTR(fg_reset), POWER_SUPPLY_ATTR(qc_opti_disable), /* Charge pump properties */ /* Charge pump properties */ POWER_SUPPLY_ATTR(cp_status1), POWER_SUPPLY_ATTR(cp_status1), POWER_SUPPLY_ATTR(cp_status2), POWER_SUPPLY_ATTR(cp_status2), Loading drivers/power/supply/qcom/qpnp-smb5.c +71 −2 Original line number Original line Diff line number Diff line Loading @@ -541,6 +541,7 @@ static enum power_supply_property smb5_usb_props[] = { POWER_SUPPLY_PROP_SMB_EN_REASON, POWER_SUPPLY_PROP_SMB_EN_REASON, POWER_SUPPLY_PROP_SCOPE, POWER_SUPPLY_PROP_SCOPE, POWER_SUPPLY_PROP_MOISTURE_DETECTED, POWER_SUPPLY_PROP_MOISTURE_DETECTED, POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED, }; }; static int smb5_usb_get_prop(struct power_supply *psy, static int smb5_usb_get_prop(struct power_supply *psy, Loading Loading @@ -685,6 +686,9 @@ static int smb5_usb_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_MOISTURE_DETECTED: case POWER_SUPPLY_PROP_MOISTURE_DETECTED: val->intval = chg->moisture_present; val->intval = chg->moisture_present; break; break; case POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED: val->intval = !chg->flash_active; break; default: default: pr_err("get prop %d is not supported in usb\n", psp); pr_err("get prop %d is not supported in usb\n", psp); rc = -EINVAL; rc = -EINVAL; Loading Loading @@ -978,6 +982,7 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, { { struct smb5 *chip = power_supply_get_drvdata(psy); struct smb5 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; union power_supply_propval pval = {0, }; int rc = 0; int rc = 0; switch (psp) { switch (psp) { Loading @@ -991,7 +996,35 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, rc = smblib_set_icl_current(chg, val->intval); rc = smblib_set_icl_current(chg, val->intval); break; break; case POWER_SUPPLY_PROP_FLASH_ACTIVE: case POWER_SUPPLY_PROP_FLASH_ACTIVE: if ((chg->smb_version == PMI632_SUBTYPE) && (chg->flash_active != val->intval)) { chg->flash_active = val->intval; chg->flash_active = val->intval; rc = smblib_get_prop_usb_present(chg, &pval); if (rc < 0) pr_err("Failed to get USB preset status rc=%d\n", rc); if (pval.intval) { rc = smblib_force_vbus_voltage(chg, chg->flash_active ? FORCE_5V_BIT : IDLE_BIT); if (rc < 0) pr_err("Failed to force 5V\n"); else chg->pulse_cnt = 0; } else { /* USB absent & flash not-active - vote 100mA */ vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, SDP_100_MA); } pr_debug("flash active VBUS 5V restriction %s\n", chg->flash_active ? "applied" : "removed"); /* Update userspace */ if (chg->batt_psy) power_supply_changed(chg->batt_psy); } break; break; case POWER_SUPPLY_PROP_TOGGLE_STAT: case POWER_SUPPLY_PROP_TOGGLE_STAT: rc = smblib_toggle_smb_en(chg, val->intval); rc = smblib_toggle_smb_en(chg, val->intval); Loading Loading @@ -1423,6 +1456,7 @@ static int smb5_batt_set_prop(struct power_supply *psy, rc = smblib_rerun_aicl(chg); rc = smblib_rerun_aicl(chg); break; break; case POWER_SUPPLY_PROP_DP_DM: case POWER_SUPPLY_PROP_DP_DM: if (!chg->flash_active) rc = smblib_dp_dm(chg, val->intval); rc = smblib_dp_dm(chg, val->intval); break; break; case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: Loading Loading @@ -1597,7 +1631,42 @@ static int smb5_init_vconn_regulator(struct smb5 *chip) ***************************/ ***************************/ static int smb5_configure_typec(struct smb_charger *chg) static int smb5_configure_typec(struct smb_charger *chg) { { union power_supply_propval pval = {0, }; int rc; int rc; u8 val = 0; rc = smblib_read(chg, LEGACY_CABLE_STATUS_REG, &val); if (rc < 0) { dev_err(chg->dev, "Couldn't read Legacy status rc=%d\n", rc); return rc; } /* * Across reboot, standard typeC cables get detected as legacy cables * due to VBUS attachment prior to CC attach/dettach. To handle this, * "early_usb_attach" flag is used, which assumes that across reboot, * the cable connected can be standard typeC. However, its jurisdiction * is limited to PD capable designs only. Hence, for non-PD type designs * reset legacy cable detection by disabling/enabling typeC mode. */ if (chg->pd_not_supported && (val & TYPEC_LEGACY_CABLE_STATUS_BIT)) { pval.intval = POWER_SUPPLY_TYPEC_PR_NONE; smblib_set_prop_typec_power_role(chg, &pval); if (rc < 0) { dev_err(chg->dev, "Couldn't disable TYPEC rc=%d\n", rc); return rc; } /* delay before enabling typeC */ msleep(50); pval.intval = POWER_SUPPLY_TYPEC_PR_DUAL; smblib_set_prop_typec_power_role(chg, &pval); if (rc < 0) { dev_err(chg->dev, "Couldn't enable TYPEC rc=%d\n", rc); return rc; } } smblib_apsd_enable(chg, true); smblib_apsd_enable(chg, true); smblib_hvdcp_detect_enable(chg, false); smblib_hvdcp_detect_enable(chg, false); Loading drivers/power/supply/qcom/schgm-flash.c +5 −0 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,11 @@ static void schgm_flash_parse_dt(struct smb_charger *chg) } } } } bool is_flash_active(struct smb_charger *chg) { return chg->flash_active ? true : false; } int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val) int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val) { { int rc, vreg_state; int rc, vreg_state; Loading drivers/power/supply/qcom/schgm-flash.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,7 @@ int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val); int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val); int schgm_flash_init(struct smb_charger *chg); int schgm_flash_init(struct smb_charger *chg); bool is_flash_active(struct smb_charger *chg); irqreturn_t schgm_flash_default_irq_handler(int irq, void *data); irqreturn_t schgm_flash_default_irq_handler(int irq, void *data); irqreturn_t schgm_flash_ilim2_irq_handler(int irq, void *data); irqreturn_t schgm_flash_ilim2_irq_handler(int irq, void *data); Loading drivers/power/supply/qcom/smb5-lib.c +39 −15 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "smb5-lib.h" #include "smb5-lib.h" #include "smb5-reg.h" #include "smb5-reg.h" #include "battery.h" #include "battery.h" #include "schgm-flash.h" #include "step-chg-jeita.h" #include "step-chg-jeita.h" #include "storm-watch.h" #include "storm-watch.h" Loading Loading @@ -746,6 +747,23 @@ static int smblib_set_adapter_allowance(struct smb_charger *chg, { { int rc = 0; int rc = 0; /* PMI632 only support max. 9V */ if (chg->smb_version == PMI632_SUBTYPE) { switch (allowed_voltage) { case USBIN_ADAPTER_ALLOW_12V: case USBIN_ADAPTER_ALLOW_9V_TO_12V: allowed_voltage = USBIN_ADAPTER_ALLOW_9V; break; case USBIN_ADAPTER_ALLOW_5V_OR_12V: case USBIN_ADAPTER_ALLOW_5V_OR_9V_TO_12V: allowed_voltage = USBIN_ADAPTER_ALLOW_5V_OR_9V; break; case USBIN_ADAPTER_ALLOW_5V_TO_12V: allowed_voltage = USBIN_ADAPTER_ALLOW_5V_TO_9V; break; } } rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG, allowed_voltage); rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG, allowed_voltage); if (rc < 0) { if (rc < 0) { smblib_err(chg, "Couldn't write 0x%02x to USBIN_ADAPTER_ALLOW_CFG rc=%d\n", smblib_err(chg, "Couldn't write 0x%02x to USBIN_ADAPTER_ALLOW_CFG rc=%d\n", Loading Loading @@ -1011,7 +1029,6 @@ int smblib_mapping_cc_delta_from_field_value(struct smb_chg_param *param, return 0; return 0; } } #define SDP_100_MA 100000 static void smblib_uusb_removal(struct smb_charger *chg) static void smblib_uusb_removal(struct smb_charger *chg) { { int rc; int rc; Loading Loading @@ -1042,7 +1059,8 @@ static void smblib_uusb_removal(struct smb_charger *chg) /* reset both usbin current and voltage votes */ /* reset both usbin current and voltage votes */ vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0); vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0); vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0); vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, SDP_100_MA); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0); vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0); vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0); vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0); Loading Loading @@ -2111,7 +2129,7 @@ static int smblib_dm_pulse(struct smb_charger *chg) return rc; return rc; } } static int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val) int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val) { { int rc; int rc; Loading Loading @@ -3369,13 +3387,6 @@ int smblib_get_prop_connector_health(struct smb_charger *chg) return POWER_SUPPLY_HEALTH_COOL; return POWER_SUPPLY_HEALTH_COOL; } } #define SDP_CURRENT_UA 500000 #define CDP_CURRENT_UA 1500000 #define DCP_CURRENT_UA 1500000 #define HVDCP_CURRENT_UA 3000000 #define TYPEC_DEFAULT_CURRENT_UA 900000 #define TYPEC_MEDIUM_CURRENT_UA 1500000 #define TYPEC_HIGH_CURRENT_UA 3000000 static int get_rp_based_dcp_current(struct smb_charger *chg, int typec_mode) static int get_rp_based_dcp_current(struct smb_charger *chg, int typec_mode) { { int rp_ua; int rp_ua; Loading Loading @@ -3415,6 +3426,7 @@ static int smblib_handle_usb_current(struct smb_charger *chg, int usb_current) int usb_current) { { int rc = 0, rp_ua, typec_mode; int rc = 0, rp_ua, typec_mode; union power_supply_propval val = {0, }; if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_FLOAT) { if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_FLOAT) { if (usb_current == -ETIMEDOUT) { if (usb_current == -ETIMEDOUT) { Loading Loading @@ -3469,8 +3481,16 @@ static int smblib_handle_usb_current(struct smb_charger *chg, return rc; return rc; } } } else { } else { rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, rc = smblib_get_prop_usb_present(chg, &val); true, usb_current); if (!rc && !val.intval) return 0; /* if flash is active force 500mA */ if ((usb_current < SDP_CURRENT_UA) && is_flash_active(chg)) usb_current = SDP_CURRENT_UA; rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, true, usb_current); if (rc < 0) { if (rc < 0) { pr_err("Couldn't vote ICL USB_PSY_VOTER rc=%d\n", rc); pr_err("Couldn't vote ICL USB_PSY_VOTER rc=%d\n", rc); return rc; return rc; Loading Loading @@ -4425,9 +4445,12 @@ static void update_sw_icl_max(struct smb_charger *chg, int pst) * enumeration is done. * enumeration is done. */ */ if (!is_client_vote_enabled(chg->usb_icl_votable, if (!is_client_vote_enabled(chg->usb_icl_votable, USB_PSY_VOTER)) USB_PSY_VOTER)) { /* if flash is active force 500mA */ vote(chg->usb_icl_votable, USB_PSY_VOTER, true, vote(chg->usb_icl_votable, USB_PSY_VOTER, true, SDP_100_MA); is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); } vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0); break; break; case POWER_SUPPLY_TYPE_USB_CDP: case POWER_SUPPLY_TYPE_USB_CDP: Loading Loading @@ -4718,7 +4741,8 @@ static void typec_src_removal(struct smb_charger *chg) cancel_delayed_work_sync(&chg->pl_enable_work); cancel_delayed_work_sync(&chg->pl_enable_work); /* reset input current limit voters */ /* reset input current limit voters */ vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, SDP_100_MA); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); vote(chg->usb_icl_votable, PD_VOTER, false, 0); vote(chg->usb_icl_votable, PD_VOTER, false, 0); vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0); vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0); vote(chg->usb_icl_votable, DCP_VOTER, false, 0); vote(chg->usb_icl_votable, DCP_VOTER, false, 0); Loading Loading
drivers/power/supply/power_supply_sysfs.c +1 −0 Original line number Original line Diff line number Diff line Loading @@ -388,6 +388,7 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(toggle_stat), POWER_SUPPLY_ATTR(toggle_stat), POWER_SUPPLY_ATTR(main_fcc_max), POWER_SUPPLY_ATTR(main_fcc_max), POWER_SUPPLY_ATTR(fg_reset), POWER_SUPPLY_ATTR(fg_reset), POWER_SUPPLY_ATTR(qc_opti_disable), /* Charge pump properties */ /* Charge pump properties */ POWER_SUPPLY_ATTR(cp_status1), POWER_SUPPLY_ATTR(cp_status1), POWER_SUPPLY_ATTR(cp_status2), POWER_SUPPLY_ATTR(cp_status2), Loading
drivers/power/supply/qcom/qpnp-smb5.c +71 −2 Original line number Original line Diff line number Diff line Loading @@ -541,6 +541,7 @@ static enum power_supply_property smb5_usb_props[] = { POWER_SUPPLY_PROP_SMB_EN_REASON, POWER_SUPPLY_PROP_SMB_EN_REASON, POWER_SUPPLY_PROP_SCOPE, POWER_SUPPLY_PROP_SCOPE, POWER_SUPPLY_PROP_MOISTURE_DETECTED, POWER_SUPPLY_PROP_MOISTURE_DETECTED, POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED, }; }; static int smb5_usb_get_prop(struct power_supply *psy, static int smb5_usb_get_prop(struct power_supply *psy, Loading Loading @@ -685,6 +686,9 @@ static int smb5_usb_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_MOISTURE_DETECTED: case POWER_SUPPLY_PROP_MOISTURE_DETECTED: val->intval = chg->moisture_present; val->intval = chg->moisture_present; break; break; case POWER_SUPPLY_PROP_HVDCP_OPTI_ALLOWED: val->intval = !chg->flash_active; break; default: default: pr_err("get prop %d is not supported in usb\n", psp); pr_err("get prop %d is not supported in usb\n", psp); rc = -EINVAL; rc = -EINVAL; Loading Loading @@ -978,6 +982,7 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, { { struct smb5 *chip = power_supply_get_drvdata(psy); struct smb5 *chip = power_supply_get_drvdata(psy); struct smb_charger *chg = &chip->chg; struct smb_charger *chg = &chip->chg; union power_supply_propval pval = {0, }; int rc = 0; int rc = 0; switch (psp) { switch (psp) { Loading @@ -991,7 +996,35 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, rc = smblib_set_icl_current(chg, val->intval); rc = smblib_set_icl_current(chg, val->intval); break; break; case POWER_SUPPLY_PROP_FLASH_ACTIVE: case POWER_SUPPLY_PROP_FLASH_ACTIVE: if ((chg->smb_version == PMI632_SUBTYPE) && (chg->flash_active != val->intval)) { chg->flash_active = val->intval; chg->flash_active = val->intval; rc = smblib_get_prop_usb_present(chg, &pval); if (rc < 0) pr_err("Failed to get USB preset status rc=%d\n", rc); if (pval.intval) { rc = smblib_force_vbus_voltage(chg, chg->flash_active ? FORCE_5V_BIT : IDLE_BIT); if (rc < 0) pr_err("Failed to force 5V\n"); else chg->pulse_cnt = 0; } else { /* USB absent & flash not-active - vote 100mA */ vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, SDP_100_MA); } pr_debug("flash active VBUS 5V restriction %s\n", chg->flash_active ? "applied" : "removed"); /* Update userspace */ if (chg->batt_psy) power_supply_changed(chg->batt_psy); } break; break; case POWER_SUPPLY_PROP_TOGGLE_STAT: case POWER_SUPPLY_PROP_TOGGLE_STAT: rc = smblib_toggle_smb_en(chg, val->intval); rc = smblib_toggle_smb_en(chg, val->intval); Loading Loading @@ -1423,6 +1456,7 @@ static int smb5_batt_set_prop(struct power_supply *psy, rc = smblib_rerun_aicl(chg); rc = smblib_rerun_aicl(chg); break; break; case POWER_SUPPLY_PROP_DP_DM: case POWER_SUPPLY_PROP_DP_DM: if (!chg->flash_active) rc = smblib_dp_dm(chg, val->intval); rc = smblib_dp_dm(chg, val->intval); break; break; case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED: Loading Loading @@ -1597,7 +1631,42 @@ static int smb5_init_vconn_regulator(struct smb5 *chip) ***************************/ ***************************/ static int smb5_configure_typec(struct smb_charger *chg) static int smb5_configure_typec(struct smb_charger *chg) { { union power_supply_propval pval = {0, }; int rc; int rc; u8 val = 0; rc = smblib_read(chg, LEGACY_CABLE_STATUS_REG, &val); if (rc < 0) { dev_err(chg->dev, "Couldn't read Legacy status rc=%d\n", rc); return rc; } /* * Across reboot, standard typeC cables get detected as legacy cables * due to VBUS attachment prior to CC attach/dettach. To handle this, * "early_usb_attach" flag is used, which assumes that across reboot, * the cable connected can be standard typeC. However, its jurisdiction * is limited to PD capable designs only. Hence, for non-PD type designs * reset legacy cable detection by disabling/enabling typeC mode. */ if (chg->pd_not_supported && (val & TYPEC_LEGACY_CABLE_STATUS_BIT)) { pval.intval = POWER_SUPPLY_TYPEC_PR_NONE; smblib_set_prop_typec_power_role(chg, &pval); if (rc < 0) { dev_err(chg->dev, "Couldn't disable TYPEC rc=%d\n", rc); return rc; } /* delay before enabling typeC */ msleep(50); pval.intval = POWER_SUPPLY_TYPEC_PR_DUAL; smblib_set_prop_typec_power_role(chg, &pval); if (rc < 0) { dev_err(chg->dev, "Couldn't enable TYPEC rc=%d\n", rc); return rc; } } smblib_apsd_enable(chg, true); smblib_apsd_enable(chg, true); smblib_hvdcp_detect_enable(chg, false); smblib_hvdcp_detect_enable(chg, false); Loading
drivers/power/supply/qcom/schgm-flash.c +5 −0 Original line number Original line Diff line number Diff line Loading @@ -101,6 +101,11 @@ static void schgm_flash_parse_dt(struct smb_charger *chg) } } } } bool is_flash_active(struct smb_charger *chg) { return chg->flash_active ? true : false; } int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val) int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val) { { int rc, vreg_state; int rc, vreg_state; Loading
drivers/power/supply/qcom/schgm-flash.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -47,6 +47,7 @@ int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val); int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val); int schgm_flash_init(struct smb_charger *chg); int schgm_flash_init(struct smb_charger *chg); bool is_flash_active(struct smb_charger *chg); irqreturn_t schgm_flash_default_irq_handler(int irq, void *data); irqreturn_t schgm_flash_default_irq_handler(int irq, void *data); irqreturn_t schgm_flash_ilim2_irq_handler(int irq, void *data); irqreturn_t schgm_flash_ilim2_irq_handler(int irq, void *data); Loading
drivers/power/supply/qcom/smb5-lib.c +39 −15 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "smb5-lib.h" #include "smb5-lib.h" #include "smb5-reg.h" #include "smb5-reg.h" #include "battery.h" #include "battery.h" #include "schgm-flash.h" #include "step-chg-jeita.h" #include "step-chg-jeita.h" #include "storm-watch.h" #include "storm-watch.h" Loading Loading @@ -746,6 +747,23 @@ static int smblib_set_adapter_allowance(struct smb_charger *chg, { { int rc = 0; int rc = 0; /* PMI632 only support max. 9V */ if (chg->smb_version == PMI632_SUBTYPE) { switch (allowed_voltage) { case USBIN_ADAPTER_ALLOW_12V: case USBIN_ADAPTER_ALLOW_9V_TO_12V: allowed_voltage = USBIN_ADAPTER_ALLOW_9V; break; case USBIN_ADAPTER_ALLOW_5V_OR_12V: case USBIN_ADAPTER_ALLOW_5V_OR_9V_TO_12V: allowed_voltage = USBIN_ADAPTER_ALLOW_5V_OR_9V; break; case USBIN_ADAPTER_ALLOW_5V_TO_12V: allowed_voltage = USBIN_ADAPTER_ALLOW_5V_TO_9V; break; } } rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG, allowed_voltage); rc = smblib_write(chg, USBIN_ADAPTER_ALLOW_CFG_REG, allowed_voltage); if (rc < 0) { if (rc < 0) { smblib_err(chg, "Couldn't write 0x%02x to USBIN_ADAPTER_ALLOW_CFG rc=%d\n", smblib_err(chg, "Couldn't write 0x%02x to USBIN_ADAPTER_ALLOW_CFG rc=%d\n", Loading Loading @@ -1011,7 +1029,6 @@ int smblib_mapping_cc_delta_from_field_value(struct smb_chg_param *param, return 0; return 0; } } #define SDP_100_MA 100000 static void smblib_uusb_removal(struct smb_charger *chg) static void smblib_uusb_removal(struct smb_charger *chg) { { int rc; int rc; Loading Loading @@ -1042,7 +1059,8 @@ static void smblib_uusb_removal(struct smb_charger *chg) /* reset both usbin current and voltage votes */ /* reset both usbin current and voltage votes */ vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0); vote(chg->pl_enable_votable_indirect, USBIN_I_VOTER, false, 0); vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0); vote(chg->pl_enable_votable_indirect, USBIN_V_VOTER, false, 0); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, SDP_100_MA); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0); vote(chg->usb_icl_votable, SW_QC3_VOTER, false, 0); vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0); vote(chg->usb_icl_votable, HVDCP2_ICL_VOTER, false, 0); Loading Loading @@ -2111,7 +2129,7 @@ static int smblib_dm_pulse(struct smb_charger *chg) return rc; return rc; } } static int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val) int smblib_force_vbus_voltage(struct smb_charger *chg, u8 val) { { int rc; int rc; Loading Loading @@ -3369,13 +3387,6 @@ int smblib_get_prop_connector_health(struct smb_charger *chg) return POWER_SUPPLY_HEALTH_COOL; return POWER_SUPPLY_HEALTH_COOL; } } #define SDP_CURRENT_UA 500000 #define CDP_CURRENT_UA 1500000 #define DCP_CURRENT_UA 1500000 #define HVDCP_CURRENT_UA 3000000 #define TYPEC_DEFAULT_CURRENT_UA 900000 #define TYPEC_MEDIUM_CURRENT_UA 1500000 #define TYPEC_HIGH_CURRENT_UA 3000000 static int get_rp_based_dcp_current(struct smb_charger *chg, int typec_mode) static int get_rp_based_dcp_current(struct smb_charger *chg, int typec_mode) { { int rp_ua; int rp_ua; Loading Loading @@ -3415,6 +3426,7 @@ static int smblib_handle_usb_current(struct smb_charger *chg, int usb_current) int usb_current) { { int rc = 0, rp_ua, typec_mode; int rc = 0, rp_ua, typec_mode; union power_supply_propval val = {0, }; if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_FLOAT) { if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_FLOAT) { if (usb_current == -ETIMEDOUT) { if (usb_current == -ETIMEDOUT) { Loading Loading @@ -3469,8 +3481,16 @@ static int smblib_handle_usb_current(struct smb_charger *chg, return rc; return rc; } } } else { } else { rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, rc = smblib_get_prop_usb_present(chg, &val); true, usb_current); if (!rc && !val.intval) return 0; /* if flash is active force 500mA */ if ((usb_current < SDP_CURRENT_UA) && is_flash_active(chg)) usb_current = SDP_CURRENT_UA; rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, true, usb_current); if (rc < 0) { if (rc < 0) { pr_err("Couldn't vote ICL USB_PSY_VOTER rc=%d\n", rc); pr_err("Couldn't vote ICL USB_PSY_VOTER rc=%d\n", rc); return rc; return rc; Loading Loading @@ -4425,9 +4445,12 @@ static void update_sw_icl_max(struct smb_charger *chg, int pst) * enumeration is done. * enumeration is done. */ */ if (!is_client_vote_enabled(chg->usb_icl_votable, if (!is_client_vote_enabled(chg->usb_icl_votable, USB_PSY_VOTER)) USB_PSY_VOTER)) { /* if flash is active force 500mA */ vote(chg->usb_icl_votable, USB_PSY_VOTER, true, vote(chg->usb_icl_votable, USB_PSY_VOTER, true, SDP_100_MA); is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); } vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0); break; break; case POWER_SUPPLY_TYPE_USB_CDP: case POWER_SUPPLY_TYPE_USB_CDP: Loading Loading @@ -4718,7 +4741,8 @@ static void typec_src_removal(struct smb_charger *chg) cancel_delayed_work_sync(&chg->pl_enable_work); cancel_delayed_work_sync(&chg->pl_enable_work); /* reset input current limit voters */ /* reset input current limit voters */ vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, SDP_100_MA); vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); vote(chg->usb_icl_votable, PD_VOTER, false, 0); vote(chg->usb_icl_votable, PD_VOTER, false, 0); vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0); vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0); vote(chg->usb_icl_votable, DCP_VOTER, false, 0); vote(chg->usb_icl_votable, DCP_VOTER, false, 0); Loading