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

Commit 2f7861a3 authored by Harry Yang's avatar Harry Yang
Browse files

power: smb5: configure input from wireless



Wireless power feeds to the DCIN input of the smb5 charger and relies
on input current configurations for power draw.

Provide means to configure the current limits via DC psy. Also set the
initial DC ICL to 1A.

Change-Id: Ic4ca30ecac2f4c0dd9080b221b4eaa2e04c4c404
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 117b43f3
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -73,6 +73,13 @@ static struct smb_params smb5_pmi632_params = {
		.max_u	= 1000000,
		.step_u	= 250000,
	},
	.dc_icl		= {
		.name   = "DC input current limit",
		.reg    = DCDC_CFG_REF_MAX_PSNS_REG,
		.min_u  = 0,
		.max_u  = 1500000,
		.step_u = 50000,
	},
	.jeita_cc_comp_hot	= {
		.name	= "jeita fcc reduction",
		.reg	= JEITA_CCCOMP_CFG_HOT_REG,
@@ -140,6 +147,13 @@ static struct smb_params smb5_pm8150b_params = {
		.max_u	= 3000000,
		.step_u	= 500000,
	},
	.dc_icl		= {
		.name   = "DC input current limit",
		.reg    = DCDC_CFG_REF_MAX_PSNS_REG,
		.min_u  = 0,
		.max_u  = 1500000,
		.step_u = 50000,
	},
	.jeita_cc_comp_hot	= {
		.name	= "jeita fcc reduction",
		.reg	= JEITA_CCCOMP_CFG_HOT_REG,
@@ -942,6 +956,7 @@ static enum power_supply_property smb5_dc_props[] = {
	POWER_SUPPLY_PROP_INPUT_SUSPEND,
	POWER_SUPPLY_PROP_PRESENT,
	POWER_SUPPLY_PROP_ONLINE,
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_REAL_TYPE,
};

@@ -963,6 +978,10 @@ static int smb5_dc_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_ONLINE:
		rc = smblib_get_prop_dc_online(chg, val);
		break;
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		rc = smblib_get_charge_param(chg, &chg->param.dc_icl,
					&val->intval);
		break;
	case POWER_SUPPLY_PROP_REAL_TYPE:
		val->intval = POWER_SUPPLY_TYPE_WIPOWER;
		break;
@@ -989,6 +1008,10 @@ static int smb5_dc_set_prop(struct power_supply *psy,
		rc = vote(chg->dc_suspend_votable, WBC_VOTER,
				(bool)val->intval, 0);
		break;
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		rc = smblib_set_charge_param(chg, &chg->param.dc_icl,
					val->intval);
		break;
	default:
		return -EINVAL;
	}
@@ -1644,6 +1667,14 @@ static int smb5_init_hw(struct smb5 *chip)
	vote(chg->usb_icl_votable, HW_LIMIT_VOTER,
			chg->hw_max_icl_ua > 0, chg->hw_max_icl_ua);

	/* set DC icl_max 1A */
	rc = smblib_set_charge_param(chg, &chg->param.dc_icl, 1000000);
	if (rc < 0) {
		dev_err(chg->dev,
			"Couldn't set dc_icl rc=%d\n", rc);
		return rc;
	}

	/*
	 * AICL configuration:
	 * start from min and AICL ADC disable, and enable aicl rerun
+1 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ struct smb_params {
	struct smb_chg_param	icl_max_stat;
	struct smb_chg_param	icl_stat;
	struct smb_chg_param	otg_cl;
	struct smb_chg_param	dc_icl;
	struct smb_chg_param	jeita_cc_comp_hot;
	struct smb_chg_param	jeita_cc_comp_cold;
	struct smb_chg_param	freq_switcher;
+2 −0
Original line number Diff line number Diff line
@@ -138,6 +138,8 @@ enum {
#define DCDC_OTG_CFG_REG			(DCDC_BASE + 0x53)
#define OTG_EN_SRC_CFG_BIT			BIT(1)

#define DCDC_CFG_REF_MAX_PSNS_REG		(DCDC_BASE + 0x8C)

/********************************
 *  BATIF Peripheral Registers  *
 ********************************/