Loading drivers/power/supply/qcom/qpnp-smbcharger.c +41 −24 Original line number Diff line number Diff line Loading @@ -1884,6 +1884,22 @@ static bool smbchg_is_usbin_active_pwr_src(struct smbchg_chip *chip) && (reg & USBIN_ACTIVE_PWR_SRC_BIT); } static void smbchg_detect_parallel_charger(struct smbchg_chip *chip) { int rc; struct power_supply *parallel_psy = get_parallel_psy(chip); union power_supply_propval pval = {0, }; if (parallel_psy) { pval.intval = true; rc = power_supply_set_property(parallel_psy, POWER_SUPPLY_PROP_PRESENT, &pval); chip->parallel_charger_detected = rc ? false : true; if (rc) pr_debug("parallel-charger absent rc=%d\n", rc); } } static int smbchg_parallel_usb_charging_en(struct smbchg_chip *chip, bool en) { struct power_supply *parallel_psy = get_parallel_psy(chip); Loading Loading @@ -2021,7 +2037,8 @@ static void smbchg_parallel_usb_taper(struct smbchg_chip *chip) int parallel_fcc_ma, tries = 0; u8 reg = 0; if (!parallel_psy || !chip->parallel_charger_detected) smbchg_detect_parallel_charger(chip); if (!chip->parallel_charger_detected) return; smbchg_stay_awake(chip, PM_PARALLEL_TAPER); Loading Loading @@ -4589,11 +4606,6 @@ static void restore_from_hvdcp_detection(struct smbchg_chip *chip) { int rc; pr_smb(PR_MISC, "Retracting HVDCP vote for ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, false, 0); if (rc < 0) pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc); /* switch to 9V HVDCP */ rc = smbchg_sec_masked_write(chip, chip->usb_chgpth_base + CHGPTH_CFG, HVDCP_ADAPTER_SEL_MASK, HVDCP_9V); Loading Loading @@ -4626,6 +4638,19 @@ static void restore_from_hvdcp_detection(struct smbchg_chip *chip) chip->hvdcp_3_det_ignore_uv = false; chip->pulse_cnt = 0; if ((chip->schg_version == QPNP_SCHG_LITE) && is_hvdcp_present(chip)) { pr_smb(PR_MISC, "Forcing 9V HVDCP 2.0\n"); rc = force_9v_hvdcp(chip); if (rc) pr_err("Failed to force 9V HVDCP=%d\n", rc); } pr_smb(PR_MISC, "Retracting HVDCP vote for ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, false, 0); if (rc < 0) pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc); } #define RESTRICTED_CHG_FCC_PERCENT 50 Loading Loading @@ -4722,8 +4747,6 @@ static bool is_usbin_uv_high(struct smbchg_chip *chip) #define HVDCP_NOTIFY_MS 2500 static void handle_usb_insertion(struct smbchg_chip *chip) { struct power_supply *parallel_psy = get_parallel_psy(chip); union power_supply_propval pval = {0, }; enum power_supply_type usb_supply_type; int rc; char *usb_type_name = "null"; Loading Loading @@ -4770,14 +4793,7 @@ static void handle_usb_insertion(struct smbchg_chip *chip) msecs_to_jiffies(HVDCP_NOTIFY_MS)); } if (parallel_psy) { pval.intval = true; rc = power_supply_set_property(parallel_psy, POWER_SUPPLY_PROP_PRESENT, &pval); chip->parallel_charger_detected = rc ? false : true; if (rc) pr_debug("parallel-charger absent rc=%d\n", rc); } smbchg_detect_parallel_charger(chip); if (chip->parallel.avail && chip->aicl_done_irq && !chip->enable_aicl_wake) { Loading Loading @@ -5437,6 +5453,12 @@ static int smbchg_prepare_for_pulsing_lite(struct smbchg_chip *chip) { int rc = 0; pr_smb(PR_MISC, "HVDCP voting for 300mA ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, true, 300); if (rc < 0) { pr_err("Couldn't vote for 300mA HVDCP ICL rc=%d\n", rc); return rc; } /* check if HVDCP is already in 5V continuous mode */ if (is_hvdcp_5v_cont_mode(chip)) { pr_smb(PR_MISC, "HVDCP by default is in 5V continuous mode\n"); Loading @@ -5463,13 +5485,6 @@ static int smbchg_prepare_for_pulsing_lite(struct smbchg_chip *chip) goto out; } pr_smb(PR_MISC, "HVDCP voting for 300mA ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, true, 300); if (rc < 0) { pr_err("Couldn't vote for 300mA HVDCP ICL rc=%d\n", rc); goto out; } pr_smb(PR_MISC, "Disable AICL\n"); smbchg_sec_masked_write(chip, chip->usb_chgpth_base + USB_AICL_CFG, AICL_EN_BIT, 0); Loading Loading @@ -6274,8 +6289,10 @@ static irqreturn_t fastchg_handler(int irq, void *_chip) struct smbchg_chip *chip = _chip; pr_smb(PR_INTERRUPT, "p2f triggered\n"); if (is_usb_present(chip) || is_dc_present(chip)) if (is_usb_present(chip) || is_dc_present(chip)) { smbchg_detect_parallel_charger(chip); smbchg_parallel_usb_check_ok(chip); } if (chip->batt_psy) power_supply_changed(chip->batt_psy); smbchg_charging_status_change(chip); Loading Loading
drivers/power/supply/qcom/qpnp-smbcharger.c +41 −24 Original line number Diff line number Diff line Loading @@ -1884,6 +1884,22 @@ static bool smbchg_is_usbin_active_pwr_src(struct smbchg_chip *chip) && (reg & USBIN_ACTIVE_PWR_SRC_BIT); } static void smbchg_detect_parallel_charger(struct smbchg_chip *chip) { int rc; struct power_supply *parallel_psy = get_parallel_psy(chip); union power_supply_propval pval = {0, }; if (parallel_psy) { pval.intval = true; rc = power_supply_set_property(parallel_psy, POWER_SUPPLY_PROP_PRESENT, &pval); chip->parallel_charger_detected = rc ? false : true; if (rc) pr_debug("parallel-charger absent rc=%d\n", rc); } } static int smbchg_parallel_usb_charging_en(struct smbchg_chip *chip, bool en) { struct power_supply *parallel_psy = get_parallel_psy(chip); Loading Loading @@ -2021,7 +2037,8 @@ static void smbchg_parallel_usb_taper(struct smbchg_chip *chip) int parallel_fcc_ma, tries = 0; u8 reg = 0; if (!parallel_psy || !chip->parallel_charger_detected) smbchg_detect_parallel_charger(chip); if (!chip->parallel_charger_detected) return; smbchg_stay_awake(chip, PM_PARALLEL_TAPER); Loading Loading @@ -4589,11 +4606,6 @@ static void restore_from_hvdcp_detection(struct smbchg_chip *chip) { int rc; pr_smb(PR_MISC, "Retracting HVDCP vote for ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, false, 0); if (rc < 0) pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc); /* switch to 9V HVDCP */ rc = smbchg_sec_masked_write(chip, chip->usb_chgpth_base + CHGPTH_CFG, HVDCP_ADAPTER_SEL_MASK, HVDCP_9V); Loading Loading @@ -4626,6 +4638,19 @@ static void restore_from_hvdcp_detection(struct smbchg_chip *chip) chip->hvdcp_3_det_ignore_uv = false; chip->pulse_cnt = 0; if ((chip->schg_version == QPNP_SCHG_LITE) && is_hvdcp_present(chip)) { pr_smb(PR_MISC, "Forcing 9V HVDCP 2.0\n"); rc = force_9v_hvdcp(chip); if (rc) pr_err("Failed to force 9V HVDCP=%d\n", rc); } pr_smb(PR_MISC, "Retracting HVDCP vote for ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, false, 0); if (rc < 0) pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc); } #define RESTRICTED_CHG_FCC_PERCENT 50 Loading Loading @@ -4722,8 +4747,6 @@ static bool is_usbin_uv_high(struct smbchg_chip *chip) #define HVDCP_NOTIFY_MS 2500 static void handle_usb_insertion(struct smbchg_chip *chip) { struct power_supply *parallel_psy = get_parallel_psy(chip); union power_supply_propval pval = {0, }; enum power_supply_type usb_supply_type; int rc; char *usb_type_name = "null"; Loading Loading @@ -4770,14 +4793,7 @@ static void handle_usb_insertion(struct smbchg_chip *chip) msecs_to_jiffies(HVDCP_NOTIFY_MS)); } if (parallel_psy) { pval.intval = true; rc = power_supply_set_property(parallel_psy, POWER_SUPPLY_PROP_PRESENT, &pval); chip->parallel_charger_detected = rc ? false : true; if (rc) pr_debug("parallel-charger absent rc=%d\n", rc); } smbchg_detect_parallel_charger(chip); if (chip->parallel.avail && chip->aicl_done_irq && !chip->enable_aicl_wake) { Loading Loading @@ -5437,6 +5453,12 @@ static int smbchg_prepare_for_pulsing_lite(struct smbchg_chip *chip) { int rc = 0; pr_smb(PR_MISC, "HVDCP voting for 300mA ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, true, 300); if (rc < 0) { pr_err("Couldn't vote for 300mA HVDCP ICL rc=%d\n", rc); return rc; } /* check if HVDCP is already in 5V continuous mode */ if (is_hvdcp_5v_cont_mode(chip)) { pr_smb(PR_MISC, "HVDCP by default is in 5V continuous mode\n"); Loading @@ -5463,13 +5485,6 @@ static int smbchg_prepare_for_pulsing_lite(struct smbchg_chip *chip) goto out; } pr_smb(PR_MISC, "HVDCP voting for 300mA ICL\n"); rc = vote(chip->usb_icl_votable, HVDCP_ICL_VOTER, true, 300); if (rc < 0) { pr_err("Couldn't vote for 300mA HVDCP ICL rc=%d\n", rc); goto out; } pr_smb(PR_MISC, "Disable AICL\n"); smbchg_sec_masked_write(chip, chip->usb_chgpth_base + USB_AICL_CFG, AICL_EN_BIT, 0); Loading Loading @@ -6274,8 +6289,10 @@ static irqreturn_t fastchg_handler(int irq, void *_chip) struct smbchg_chip *chip = _chip; pr_smb(PR_INTERRUPT, "p2f triggered\n"); if (is_usb_present(chip) || is_dc_present(chip)) if (is_usb_present(chip) || is_dc_present(chip)) { smbchg_detect_parallel_charger(chip); smbchg_parallel_usb_check_ok(chip); } if (chip->batt_psy) power_supply_changed(chip->batt_psy); smbchg_charging_status_change(chip); Loading