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

Commit 88c91971 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Vamshi Krishna B V
Browse files

power: qpnp-smbcharger: Add POWER_SUPPLY_PROP_MAX_PULSE_ALLOWED property



Use this property to specify the maximum pulses which can be allowed
during HVDCP3. The DT property 'qcom,max-pulse-allowed' can be
specified to initialize this value.

CRs-Fixed: 1047232
Change-Id: I3d1aa92b16d2103b7f3df88ca948423c202b17ef
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
Signed-off-by: default avatarVamshi Krishna B V <vbv@codeaurora.org>
parent d5fc4602
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -282,6 +282,9 @@ Optional Properties:
						battery.
						battery.
- qcom,vchg_sns-vadc		Phandle of the VADC node.
- qcom,vchg_sns-vadc		Phandle of the VADC node.
- qcom,vchg-adc-channel-id	The ADC channel to which the VCHG is routed.
- qcom,vchg-adc-channel-id	The ADC channel to which the VCHG is routed.
- qcom,max-pulse-allowed	The maximum number of pulses allowed in
				HVDCP3 mode. It can be used to restrict VBUS
				to a value.


Example:
Example:
	qcom,qpnp-smbcharger {
	qcom,qpnp-smbcharger {
+11 −0
Original line number Original line Diff line number Diff line
@@ -176,6 +176,7 @@ struct smbchg_chip {
	int				n_vbat_samples;
	int				n_vbat_samples;


	/* status variables */
	/* status variables */
	int				max_pulse_allowed;
	int				wake_reasons;
	int				wake_reasons;
	int				previous_soc;
	int				previous_soc;
	int				usb_online;
	int				usb_online;
@@ -5744,6 +5745,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_RERUN_AICL,
	POWER_SUPPLY_PROP_RERUN_AICL,
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
	POWER_SUPPLY_PROP_ALLOW_HVDCP3,
	POWER_SUPPLY_PROP_ALLOW_HVDCP3,
	POWER_SUPPLY_PROP_MAX_PULSE_ALLOWED,
};
};


static int smbchg_battery_set_property(struct power_supply *psy,
static int smbchg_battery_set_property(struct power_supply *psy,
@@ -5954,6 +5956,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		val->intval = chip->allow_hvdcp3_detection;
		val->intval = chip->allow_hvdcp3_detection;
		break;
		break;
	case POWER_SUPPLY_PROP_MAX_PULSE_ALLOWED:
		val->intval = chip->max_pulse_allowed;
		break;
	default:
	default:
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -7306,6 +7311,7 @@ static int smb_parse_wipower_dt(struct smbchg_chip *chip)


#define DEFAULT_VLED_MAX_UV		3500000
#define DEFAULT_VLED_MAX_UV		3500000
#define DEFAULT_FCC_MA			2000
#define DEFAULT_FCC_MA			2000
#define DEFAULT_NUM_OF_PULSE_ALLOWED	20
static int smb_parse_dt(struct smbchg_chip *chip)
static int smb_parse_dt(struct smbchg_chip *chip)
{
{
	int rc = 0, ocp_thresh = -EINVAL;
	int rc = 0, ocp_thresh = -EINVAL;
@@ -7364,6 +7370,11 @@ static int smb_parse_dt(struct smbchg_chip *chip)
	if (chip->parallel.min_current_thr_ma != -EINVAL
	if (chip->parallel.min_current_thr_ma != -EINVAL
			&& chip->parallel.min_9v_current_thr_ma != -EINVAL)
			&& chip->parallel.min_9v_current_thr_ma != -EINVAL)
		chip->parallel.avail = true;
		chip->parallel.avail = true;

	OF_PROP_READ(chip, chip->max_pulse_allowed,
				"max-pulse-allowed", rc, 1);
	if (chip->max_pulse_allowed == -EINVAL)
		chip->max_pulse_allowed = DEFAULT_NUM_OF_PULSE_ALLOWED;
	/*
	/*
	 * use the dt values if they exist, otherwise do not touch the params
	 * use the dt values if they exist, otherwise do not touch the params
	 */
	 */