Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a40827c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-smbcharger: icl_override for usb_cdp"

parents c4a365c5 1afdef62
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -175,6 +175,18 @@
			qcom,adc-vdd-reference = <1800>;
			qcom,vadc-poll-eoc;
			qcom,vadc-meas-int-mode;
			qcom,pmic-revid = <&pmi8994_revid>;

			chan@d {
				label = "chg_temp";
				reg = <0xd>;
				qcom,decimation = <0>;
				qcom,pre-div-channel-scaling = <0>;
				qcom,calibration-type = "absolute";
				qcom,scale-function = <16>;
				qcom,hw-settle-time = <0>;
				qcom,fast-avg-setup = <0>;
			};
		};

		pmi8994_charger: qcom,qpnp-smbcharger {
+68 −28
Original line number Diff line number Diff line
@@ -381,6 +381,7 @@ struct fg_chip {
	struct work_struct	set_resume_soc_work;
	struct work_struct	rslow_comp_work;
	struct work_struct	sysfs_restart_work;
	struct work_struct	init_work;
	struct power_supply	*batt_psy;
	struct power_supply	*usb_psy;
	struct power_supply	*dc_psy;
@@ -1049,6 +1050,12 @@ static int fg_check_iacs_ready(struct fg_chip *chip)
	int rc = 0, timeout = 250;
	u8 ima_opr_sts = 0;

	/*
	 * Additional delay to make sure IACS ready bit is set after
	 * Read/Write operation.
	 */

	usleep_range(30, 35);
	while (1) {
		rc = fg_read(chip, &ima_opr_sts,
			chip->mem_base + MEM_INTF_IMA_OPR_STS, 1);
@@ -1058,7 +1065,7 @@ static int fg_check_iacs_ready(struct fg_chip *chip)
			if (!(--timeout) || rc)
				break;
			/* delay for iacs_ready to be asserted */
			usleep_range(10000, 12000);
			usleep_range(5000, 7000);
		}
	}

@@ -3829,6 +3836,17 @@ wait:
	if (rc)
		pr_warn("couldn't find battery max voltage\n");

	/*
	 * Only configure from profile if fg-cc-cv-threshold-mv is not
	 * defined in the charger device node.
	 */
	if (!of_find_property(chip->spmi->dev.of_node,
				"qcom,fg-cc-cv-threshold-mv", NULL)) {
		of_property_read_u32(profile_node,
				"qcom,fg-cc-cv-threshold-mv",
				&chip->cc_cv_threshold_mv);
	}

	data = of_get_property(profile_node, "qcom,fg-profile-data", &len);
	if (!data) {
		pr_err("no battery profile loaded\n");
@@ -4392,10 +4410,8 @@ static int fg_init_irqs(struct fg_chip *chip)
	return rc;
}

static int fg_remove(struct spmi_device *spmi)
static void fg_cleanup(struct fg_chip *chip)
{
	struct fg_chip *chip = dev_get_drvdata(&spmi->dev);

	cancel_delayed_work_sync(&chip->update_sram_data);
	cancel_delayed_work_sync(&chip->update_temp_work);
	cancel_delayed_work_sync(&chip->update_jeita_setting);
@@ -4410,6 +4426,7 @@ static int fg_remove(struct spmi_device *spmi)
	cancel_work_sync(&chip->cycle_count_work);
	cancel_work_sync(&chip->update_esr_work);
	cancel_work_sync(&chip->sysfs_restart_work);
	cancel_work_sync(&chip->init_work);
	power_supply_unregister(&chip->bms_psy);
	mutex_destroy(&chip->rslow_comp.lock);
	mutex_destroy(&chip->rw_lock);
@@ -4422,6 +4439,13 @@ static int fg_remove(struct spmi_device *spmi)
	wakeup_source_trash(&chip->profile_wakeup_source.source);
	wakeup_source_trash(&chip->update_temp_wakeup_source.source);
	wakeup_source_trash(&chip->update_sram_wakeup_source.source);
}

static int fg_remove(struct spmi_device *spmi)
{
	struct fg_chip *chip = dev_get_drvdata(&spmi->dev);

	fg_cleanup(chip);
	dev_set_drvdata(&spmi->dev, NULL);
	return 0;
}
@@ -5154,6 +5178,43 @@ static int fg_detect_pmic_type(struct fg_chip *chip)
}

#define INIT_JEITA_DELAY_MS 1000

static void delayed_init_work(struct work_struct *work)
{
	int rc;
	struct fg_chip *chip = container_of(work,
				struct fg_chip,
				init_work);

	/* hold memory access until initialization finishes */
	fg_mem_lock(chip);

	rc = fg_hw_init(chip);
	if (rc) {
		pr_err("failed to hw init rc = %d\n", rc);
		fg_mem_release(chip);
		fg_cleanup(chip);
		return;
	}
	/* release memory access before update_sram_data is called */
	fg_mem_release(chip);

	schedule_delayed_work(
		&chip->update_jeita_setting,
		msecs_to_jiffies(INIT_JEITA_DELAY_MS));

	if (chip->last_sram_update_time == 0)
		update_sram_data_work(&chip->update_sram_data.work);

	if (chip->last_temp_update_time == 0)
		update_temp_data(&chip->update_temp_work.work);

	if (!chip->use_otp_profile)
		schedule_work(&chip->batt_profile_init);

	pr_debug("FG: HW_init success\n");
}

static int fg_probe(struct spmi_device *spmi)
{
	struct device *dev = &(spmi->dev);
@@ -5213,6 +5274,7 @@ static int fg_probe(struct spmi_device *spmi)
	INIT_WORK(&chip->update_esr_work, update_esr_value);
	INIT_WORK(&chip->set_resume_soc_work, set_resume_soc_work);
	INIT_WORK(&chip->sysfs_restart_work, sysfs_restart_work);
	INIT_WORK(&chip->init_work, delayed_init_work);
	alarm_init(&chip->fg_cap_learning_alarm, ALARM_BOOTTIME,
			fg_cap_learning_alarm_cb);
	init_completion(&chip->sram_access_granted);
@@ -5299,9 +5361,6 @@ static int fg_probe(struct spmi_device *spmi)
		goto of_init_fail;
	}

	/* hold memory access until initialization finishes */
	atomic_add_return(1, &chip->memif_user_cnt);

	rc = fg_init_irqs(chip);
	if (rc) {
		pr_err("failed to request interrupts %d\n", rc);
@@ -5341,27 +5400,7 @@ static int fg_probe(struct spmi_device *spmi)
		}
	}

	schedule_delayed_work(
		&chip->update_jeita_setting,
		msecs_to_jiffies(INIT_JEITA_DELAY_MS));

	if (chip->last_sram_update_time == 0)
		update_sram_data_work(&chip->update_sram_data.work);

	if (chip->last_temp_update_time == 0)
		update_temp_data(&chip->update_temp_work.work);

	rc = fg_hw_init(chip);
	if (rc) {
		pr_err("failed to hw init rc = %d\n", rc);
		goto power_supply_unregister;
	}

	/* release memory access if necessary */
	fg_release_access_if_necessary(chip);

	if (!chip->use_otp_profile)
		schedule_work(&chip->batt_profile_init);
	schedule_work(&chip->init_work);

	pr_info("FG Probe success - FG Revision DIG:%d.%d ANA:%d.%d PMIC subtype=%d\n",
		chip->revision[DIG_MAJOR], chip->revision[DIG_MINOR],
@@ -5387,6 +5426,7 @@ cancel_work:
	cancel_work_sync(&chip->update_esr_work);
	cancel_work_sync(&chip->rslow_comp_work);
	cancel_work_sync(&chip->sysfs_restart_work);
	cancel_work_sync(&chip->init_work);
of_init_fail:
	mutex_destroy(&chip->rslow_comp.lock);
	mutex_destroy(&chip->rw_lock);
+215 −204

File changed.

Preview size limit exceeded, changes collapsed.

+92 −30

File changed.

Preview size limit exceeded, changes collapsed.

+9 −1
Original line number Diff line number Diff line
@@ -1723,6 +1723,13 @@ static int smb135x_parallel_set_chg_present(struct smb135x_chg *chip,
	u8 val;
	int rc;

	/* Check if SMB135x is present */
	rc = smb135x_read(chip, VERSION1_REG, &val);
	if (rc) {
		pr_debug("Failed to detect smb135x-parallel charger may be absent\n");
		return -ENODEV;
	}

	if (present == chip->parallel_charger_present) {
		pr_debug("present %d -> %d, skipping\n",
				chip->parallel_charger_present, present);
@@ -2689,7 +2696,8 @@ static int handle_usb_insertion(struct smb135x_chg *chip)
	usb_supply_type = get_usb_supply_type(reg);
	pr_debug("inserted %s, usb psy type = %d stat_5 = 0x%02x apsd_rerun = %d\n",
			usb_type_name, usb_supply_type, reg, chip->apsd_rerun);
	if (!chip->apsd_rerun && chip->usb_psy) {

	if (chip->batt_present && !chip->apsd_rerun && chip->usb_psy) {
		if (usb_supply_type == POWER_SUPPLY_TYPE_USB) {
			pr_debug("setting usb psy allow detection 1 SDP and rerun\n");
			power_supply_set_allow_detection(chip->usb_psy, 1);