Loading drivers/power/supply/qcom/qpnp-smb5.c +4 −0 Original line number Diff line number Diff line Loading @@ -985,6 +985,10 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, 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", Loading drivers/power/supply/qcom/schgm-flash.c +5 −0 Original line number 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 rc, vreg_state; Loading drivers/power/supply/qcom/schgm-flash.h +1 −0 Original line number 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_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_ilim2_irq_handler(int irq, void *data); Loading drivers/power/supply/qcom/smb5-lib.c +21 −14 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include "smb5-lib.h" #include "smb5-reg.h" #include "battery.h" #include "schgm-flash.h" #include "step-chg-jeita.h" #include "storm-watch.h" Loading Loading @@ -705,7 +706,6 @@ int smblib_mapping_cc_delta_from_field_value(struct smb_chg_param *param, return 0; } #define SDP_100_MA 100000 static void smblib_uusb_removal(struct smb_charger *chg) { int rc; Loading @@ -730,7 +730,8 @@ static void smblib_uusb_removal(struct smb_charger *chg) /* 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_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); /* reconfigure allowed voltage for HVDCP */ Loading Loading @@ -2159,13 +2160,6 @@ int smblib_get_prop_die_health(struct smb_charger *chg, return 0; } #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) { int rp_ua; Loading Loading @@ -2205,6 +2199,7 @@ static int smblib_handle_usb_current(struct smb_charger *chg, int usb_current) { int rc = 0, rp_ua, typec_mode; union power_supply_propval val = {0, }; if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_FLOAT) { if (usb_current == -ETIMEDOUT) { Loading Loading @@ -2259,8 +2254,16 @@ static int smblib_handle_usb_current(struct smb_charger *chg, return rc; } } else { rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, true, usb_current); rc = smblib_get_prop_usb_present(chg, &val); 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) { pr_err("Couldn't vote ICL USB_PSY_VOTER rc=%d\n", rc); return rc; Loading Loading @@ -3028,9 +3031,12 @@ static void update_sw_icl_max(struct smb_charger *chg, int pst) * enumeration is done. */ 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, SDP_100_MA); is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); } vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0); break; case POWER_SUPPLY_TYPE_USB_CDP: Loading Loading @@ -3235,7 +3241,8 @@ static void typec_src_removal(struct smb_charger *chg) cancel_delayed_work_sync(&chg->pl_enable_work); /* 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, USB_PSY_VOTER, false, 0); vote(chg->usb_icl_votable, DCP_VOTER, false, 0); Loading drivers/power/supply/qcom/smb5-lib.h +9 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,15 @@ enum print_reason { #define VBAT_TO_VRAW_ADC(v) div_u64((u64)v * 1000000UL, 194637UL) #define SDP_100_MA 100000 #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 enum smb_mode { PARALLEL_MASTER = 0, PARALLEL_SLAVE, Loading Loading
drivers/power/supply/qcom/qpnp-smb5.c +4 −0 Original line number Diff line number Diff line Loading @@ -985,6 +985,10 @@ static int smb5_usb_main_set_prop(struct power_supply *psy, 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", Loading
drivers/power/supply/qcom/schgm-flash.c +5 −0 Original line number 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 rc, vreg_state; Loading
drivers/power/supply/qcom/schgm-flash.h +1 −0 Original line number 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_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_ilim2_irq_handler(int irq, void *data); Loading
drivers/power/supply/qcom/smb5-lib.c +21 −14 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include "smb5-lib.h" #include "smb5-reg.h" #include "battery.h" #include "schgm-flash.h" #include "step-chg-jeita.h" #include "storm-watch.h" Loading Loading @@ -705,7 +706,6 @@ int smblib_mapping_cc_delta_from_field_value(struct smb_chg_param *param, return 0; } #define SDP_100_MA 100000 static void smblib_uusb_removal(struct smb_charger *chg) { int rc; Loading @@ -730,7 +730,8 @@ static void smblib_uusb_removal(struct smb_charger *chg) /* 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_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); /* reconfigure allowed voltage for HVDCP */ Loading Loading @@ -2159,13 +2160,6 @@ int smblib_get_prop_die_health(struct smb_charger *chg, return 0; } #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) { int rp_ua; Loading Loading @@ -2205,6 +2199,7 @@ static int smblib_handle_usb_current(struct smb_charger *chg, int usb_current) { int rc = 0, rp_ua, typec_mode; union power_supply_propval val = {0, }; if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_FLOAT) { if (usb_current == -ETIMEDOUT) { Loading Loading @@ -2259,8 +2254,16 @@ static int smblib_handle_usb_current(struct smb_charger *chg, return rc; } } else { rc = vote(chg->usb_icl_votable, USB_PSY_VOTER, true, usb_current); rc = smblib_get_prop_usb_present(chg, &val); 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) { pr_err("Couldn't vote ICL USB_PSY_VOTER rc=%d\n", rc); return rc; Loading Loading @@ -3028,9 +3031,12 @@ static void update_sw_icl_max(struct smb_charger *chg, int pst) * enumeration is done. */ 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, SDP_100_MA); is_flash_active(chg) ? SDP_CURRENT_UA : SDP_100_MA); } vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, false, 0); break; case POWER_SUPPLY_TYPE_USB_CDP: Loading Loading @@ -3235,7 +3241,8 @@ static void typec_src_removal(struct smb_charger *chg) cancel_delayed_work_sync(&chg->pl_enable_work); /* 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, USB_PSY_VOTER, false, 0); vote(chg->usb_icl_votable, DCP_VOTER, false, 0); Loading
drivers/power/supply/qcom/smb5-lib.h +9 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,15 @@ enum print_reason { #define VBAT_TO_VRAW_ADC(v) div_u64((u64)v * 1000000UL, 194637UL) #define SDP_100_MA 100000 #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 enum smb_mode { PARALLEL_MASTER = 0, PARALLEL_SLAVE, Loading