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

Commit a05f1015 authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: smb5: initialize OTG current configuration



Update OTG current limit configuration during hardware
initialization.

Change-Id: I18084e96e9557e0291dd0fc681c755e44a4ad5c7
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent c595ea51
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -289,6 +289,7 @@ static int smb5_chg_config_init(struct smb5 *chip)

#define MICRO_1P5A			1500000
#define MICRO_P1A			100000
#define MICRO_1PA			1000000
#define OTG_DEFAULT_DEGLITCH_TIME_MS	50
#define MIN_WD_BARK_TIME		16
#define DEFAULT_WD_BARK_TIME		64
@@ -348,7 +349,8 @@ static int smb5_parse_dt(struct smb5 *chip)
	rc = of_property_read_u32(node,
				"qcom,otg-cl-ua", &chg->otg_cl_ua);
	if (rc < 0)
		chg->otg_cl_ua = MICRO_1P5A;
		chg->otg_cl_ua = (chip->chg.smb_version == PMI632_SUBTYPE) ?
							MICRO_1PA : MICRO_1P5A;

	rc = of_property_read_u32(node, "qcom,chg-term-src",
			&chip->dt.term_current_src);
@@ -1797,6 +1799,13 @@ static int smb5_init_hw(struct smb5 *chip)
		return rc;
	}

	/* set OTG current limit */
	rc = smblib_set_charge_param(chg, &chg->param.otg_cl, chg->otg_cl_ua);
	if (rc < 0) {
		pr_err("Couldn't set otg current limit rc=%d\n", rc);
		return rc;
	}

	/* vote 0mA on usb_icl for non battery platforms */
	vote(chg->usb_icl_votable,
		DEFAULT_VOTER, chip->dt.no_battery, 0);
@@ -2597,16 +2606,16 @@ static int smb5_probe(struct platform_device *pdev)
		return -EINVAL;
	}

	rc = smb5_parse_dt(chip);
	rc = smb5_chg_config_init(chip);
	if (rc < 0) {
		pr_err("Couldn't parse device tree rc=%d\n", rc);
		if (rc != -EPROBE_DEFER)
			pr_err("Couldn't setup chg_config rc=%d\n", rc);
		return rc;
	}

	rc = smb5_chg_config_init(chip);
	rc = smb5_parse_dt(chip);
	if (rc < 0) {
		if (rc != -EPROBE_DEFER)
			pr_err("Couldn't setup chg_config rc=%d\n", rc);
		pr_err("Couldn't parse device tree rc=%d\n", rc);
		return rc;
	}