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

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

Merge "qcom-charger: smb2: configure input from wipower"

parents e698c6ee bc356bec
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -50,6 +50,12 @@ Charger specific properties:
  Value type: <u32>
  Definition: Specifies the DC input current limit in micro-amps.

- qcom,wipower-max-uw
  Usage:      optional
  Value type: <u32>
  Definition: Specifies the DC input power limit in micro-watts.
		If the value is not present, 8W is used as default.

=============================================
Second Level Nodes - SMB2 Charger Peripherals
=============================================
@@ -80,9 +86,7 @@ pmicobalt_charger: qcom,qpnp-smb2 {
	#address-cells = <1>;
	#size-cells = <1>;

	qcom,pmic-revid = <&pmicobalt_revid>;
	qcom,suspend-input;
	qcom,disable-charging;
	dpdm-supply = <&qusb_phy0>;

	qcom,chgr@1000 {
+124 −17
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#define SMB2_DEFAULT_FCC_UA	3000000
#define SMB2_DEFAULT_FV_UV	4350000
#define SMB2_DEFAULT_ICL_UA	3000000
#define SMB2_DEFAULT_WPWR_UW	8000000

static struct smb_params v1_params = {
	.fcc			= {
@@ -40,15 +41,15 @@ static struct smb_params v1_params = {
	.fv			= {
		.name	= "float voltage",
		.reg	= FLOAT_VOLTAGE_CFG_REG,
		.min_u	= 3487500,
		.max_u	= 4920000,
		.step_u	= 7500,
		.min_u	= 2500000,
		.max_u	= 5000000,
		.step_u	= 10000,
	},
	.usb_icl		= {
		.name	= "usb input current limit",
		.reg	= USBIN_CURRENT_LIMIT_CFG_REG,
		.min_u	= 0,
		.max_u	= 4800000,
		.max_u	= 6000000,
		.step_u	= 25000,
	},
	.icl_stat		= {
@@ -62,6 +63,48 @@ static struct smb_params v1_params = {
		.name	= "dc input current limit",
		.reg	= DCIN_CURRENT_LIMIT_CFG_REG,
		.min_u	= 0,
		.max_u	= 6000000,
		.step_u	= 25000,
	},
	.dc_icl_pt_lv		= {
		.name	= "dc icl PT <8V",
		.reg	= ZIN_ICL_PT_REG,
		.min_u	= 0,
		.max_u	= 3000000,
		.step_u	= 25000,
	},
	.dc_icl_pt_hv		= {
		.name	= "dc icl PT >8V",
		.reg	= ZIN_ICL_PT_HV_REG,
		.min_u	= 0,
		.max_u	= 3000000,
		.step_u	= 25000,
	},
	.dc_icl_div2_lv		= {
		.name	= "dc icl div2 <5.5V",
		.reg	= ZIN_ICL_LV_REG,
		.min_u	= 0,
		.max_u	= 3000000,
		.step_u	= 25000,
	},
	.dc_icl_div2_mid_lv	= {
		.name	= "dc icl div2 5.5-6.5V",
		.reg	= ZIN_ICL_MID_LV_REG,
		.min_u	= 0,
		.max_u	= 3000000,
		.step_u	= 25000,
	},
	.dc_icl_div2_mid_hv	= {
		.name	= "dc icl div2 6.5-8.0V",
		.reg	= ZIN_ICL_MID_HV_REG,
		.min_u	= 0,
		.max_u	= 3000000,
		.step_u	= 25000,
	},
	.dc_icl_div2_hv		= {
		.name	= "dc icl div2 >8.0V",
		.reg	= ZIN_ICL_HV_REG,
		.min_u	= 0,
		.max_u	= 3000000,
		.step_u	= 25000,
	},
@@ -73,6 +116,7 @@ struct smb_dt_props {
	int	usb_icl_ua;
	int	dc_icl_ua;
	int	fv_uv;
	int	wipower_max_uw;
};

struct smb2 {
@@ -125,6 +169,11 @@ static int smb2_parse_dt(struct smb2 *chip)
	if (rc < 0)
		chip->dt.dc_icl_ua = SMB2_DEFAULT_ICL_UA;

	rc = of_property_read_u32(node,
			"qcom,wipower-max-uw", &chip->dt.wipower_max_uw);
	if (rc < 0)
		chip->dt.wipower_max_uw	= SMB2_DEFAULT_WPWR_UW;

	return 0;
}

@@ -486,6 +535,57 @@ static int smb2_init_vconn_regulator(struct smb2 *chip)
/***************************
 * HARDWARE INITIALIZATION *
 ***************************/
static int smb2_config_wipower_input_power(struct smb2 *chip, int uw)
{
	int rc;
	int ua;
	struct smb_charger *chg = &chip->chg;
	s64 nw = (s64)uw * 1000;

	ua = div_s64(nw, ZIN_ICL_PT_MAX_MV);
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl_pt_lv, ua);
	if (rc < 0) {
		pr_err("Couldn't configure dc_icl_pt_lv rc = %d\n", rc);
		return rc;
	}

	ua = div_s64(nw, ZIN_ICL_PT_HV_MAX_MV);
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl_pt_hv, ua);
	if (rc < 0) {
		pr_err("Couldn't configure dc_icl_pt_hv rc = %d\n", rc);
		return rc;
	}

	ua = div_s64(nw, ZIN_ICL_LV_MAX_MV);
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_lv, ua);
	if (rc < 0) {
		pr_err("Couldn't configure dc_icl_div2_lv rc = %d\n", rc);
		return rc;
	}

	ua = div_s64(nw, ZIN_ICL_MID_LV_MAX_MV);
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_mid_lv, ua);
	if (rc < 0) {
		pr_err("Couldn't configure dc_icl_div2_mid_lv rc = %d\n", rc);
		return rc;
	}

	ua = div_s64(nw, ZIN_ICL_MID_HV_MAX_MV);
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_mid_hv, ua);
	if (rc < 0) {
		pr_err("Couldn't configure dc_icl_div2_mid_hv rc = %d\n", rc);
		return rc;
	}

	ua = div_s64(nw, ZIN_ICL_HV_MAX_MV);
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_hv, ua);
	if (rc < 0) {
		pr_err("Couldn't configure dc_icl_div2_hv rc = %d\n", rc);
		return rc;
	}

	return 0;
}

static int smb2_init_hw(struct smb2 *chip)
{
@@ -582,6 +682,13 @@ static int smb2_init_hw(struct smb2 *chip)
		return rc;
	}

	/* configure wipower watts */
	rc = smb2_config_wipower_input_power(chip, chip->dt.wipower_max_uw);
	if (rc < 0) {
		dev_err(chg->dev, "Couldn't configure wipower rc=%d\n", rc);
		return rc;
	}

	return rc;
}

+6 −0
Original line number Diff line number Diff line
@@ -62,6 +62,12 @@ struct smb_params {
	struct smb_chg_param	usb_icl;
	struct smb_chg_param	icl_stat;
	struct smb_chg_param	dc_icl;
	struct smb_chg_param	dc_icl_pt_lv;
	struct smb_chg_param	dc_icl_pt_hv;
	struct smb_chg_param	dc_icl_div2_lv;
	struct smb_chg_param	dc_icl_div2_mid_lv;
	struct smb_chg_param	dc_icl_div2_mid_hv;
	struct smb_chg_param	dc_icl_div2_hv;
};

struct parallel_params {
+9 −0
Original line number Diff line number Diff line
@@ -719,6 +719,15 @@ enum {
#define ZIN_ICL_MID_HV_REG			(DCIN_BASE + 0x98)
#define ZIN_ICL_MID_HV_MASK			GENMASK(7, 0)

enum {
	ZIN_ICL_PT_MAX_MV = 8000,
	ZIN_ICL_PT_HV_MAX_MV = 9000,
	ZIN_ICL_LV_MAX_MV = 5500,
	ZIN_ICL_MID_LV_MAX_MV = 6500,
	ZIN_ICL_MID_HV_MAX_MV = 8000,
	ZIN_ICL_HV_MAX_MV = 11000,
};

/* MISC Peripheral Registers */
#define REVISION1_REG				(MISC_BASE + 0x00)
#define DIG_MINOR_MASK				GENMASK(7, 0)