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

Commit f24fcd17 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-qg: Minor modifications in QG"

parents c06921ab e4923386
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -144,6 +144,12 @@ First Level Node - QGAUGE device
	Value type: <u32>
	Definition: Resistance of the battery connectors in mOhms.

- qcom,ignore-shutdown-soc-secs
	Usage:      optional
	Value type: <u32>
	Definition: Time in seconds beyond which shutdown SOC is ignored.
		    If not specified the default value is 360 secs.

==========================================================
Second Level Nodes - Peripherals managed by QGAUGE driver
==========================================================
+4 −18
Original line number Diff line number Diff line
@@ -393,33 +393,19 @@ static int qg_parse_battery_profile(struct qg_battery_data *battery)
	return rc;
}

int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, u8 lookup)
int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, bool charging)
{
	u8 table_index = 0;
	int soc_avg = 0, soc_charge = 0, soc_discharge = 0;
	u8 table_index = charging ? TABLE_SOC_OCV1 : TABLE_SOC_OCV2;

	if (!the_battery || !the_battery->profile) {
		pr_err("Battery profile not loaded\n");
		return -ENODEV;
	}

	if (lookup == SOC_AVERAGE) {
		soc_charge = interpolate_soc(
				&the_battery->profile[TABLE_SOC_OCV1],
	*soc = interpolate_soc(&the_battery->profile[table_index],
				batt_temp, UV_TO_DECIUV(ocv_uv));
		soc_discharge = interpolate_soc(
				&the_battery->profile[TABLE_SOC_OCV2],
				batt_temp, UV_TO_DECIUV(ocv_uv));
		soc_avg = (soc_charge + soc_discharge) / 2;
	} else {
		table_index = (lookup == SOC_CHARGE) ?
				TABLE_SOC_OCV1 : TABLE_SOC_OCV2;
		soc_avg = interpolate_soc(
				&the_battery->profile[table_index],
				batt_temp, UV_TO_DECIUV(ocv_uv));
	}

	*soc = CAP(0, 100, DIV_ROUND_CLOSEST(soc_avg, 100));
	*soc = CAP(0, 100, DIV_ROUND_CLOSEST(*soc, 100));

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -14,6 +14,6 @@

int qg_batterydata_init(struct device_node *node);
void qg_batterydata_exit(void);
int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, u8 lookup);
int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, bool charging);

#endif /* __QG_BATTERY_PROFILE_H__ */
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ struct qg_dt {
	int			s3_exit_ibat_ua;
	int			delta_soc;
	int			rbat_conn_mohm;
	int			ignore_shutdown_soc_secs;
};

struct qpnp_qg {
@@ -79,6 +80,7 @@ struct qpnp_qg {

	/* status variable */
	u32			*debug_mask;
	bool			qg_device_open;
	bool			profile_loaded;
	bool			battery_missing;
	bool			data_ready;
+0 −6
Original line number Diff line number Diff line
@@ -45,10 +45,4 @@
#define CAP(min, max, value)			\
		((min > value) ? min : ((value > max) ? max : value))

enum soc_lookup {
	SOC_CHARGE,
	SOC_DISCHARGE,
	SOC_AVERAGE,
};

#endif /* __QG_DEFS_H__ */
Loading