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

Commit d1d740db authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-qg: Add support for PM6150 Qgauge"

parents 0b053c6e f05c2546
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ struct qpnp_qg {
	struct votable		*fifo_irq_disable_votable;
	struct votable		*good_ocv_irq_disable_votable;
	u32			qg_base;
	u8			qg_subtype;

	/* local data variables */
	u32			batt_id_ohm;
@@ -206,6 +207,7 @@ enum qg_irq {
enum qg_wa_flags {
	QG_VBAT_LOW_WA = BIT(0),
	QG_RECHARGE_SOC_WA = BIT(1),
	QG_CLK_ADJUST_WA = BIT(2),
};


+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#define TTF_AWAKE_VOTER			"TTF_AWAKE_VOTER"

#define V_RAW_TO_UV(V_RAW)		div_u64(194637ULL * (u64)V_RAW, 1000)
#define I_RAW_TO_UA(I_RAW)		div_s64(152588LL * (s64)I_RAW, 1000)
#define FIFO_V_RESET_VAL		0x8000
#define FIFO_I_RESET_VAL		0x8000

+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,11 @@
#define __QG_REG_H__

#define PERPH_TYPE_REG				0x04

#define PERPH_SUBTYPE_REG			0x05
#define QG_ADC_IBAT_5A				0x3
#define QG_ADC_IBAT_10A				0x4

#define QG_TYPE					0x0D

#define QG_STATUS1_REG				0x08
+16 −1
Original line number Diff line number Diff line
@@ -127,6 +127,14 @@ int qg_read_raw_data(struct qpnp_qg *chip, int addr, u32 *data)
	return rc;
}

s64 qg_iraw_to_ua(struct qpnp_qg *chip, int iraw)
{
	if (chip->qg_subtype == QG_ADC_IBAT_5A)
		return div_s64(152588LL * (s64)iraw, 1000);
	else
		return div_s64(305176LL * (s64)iraw, 1000);
}

int get_fifo_length(struct qpnp_qg *chip, u32 *fifo_length, bool rt)
{
	int rc;
@@ -167,6 +175,8 @@ int get_sample_count(struct qpnp_qg *chip, u32 *sample_count)
	return rc;
}

#define QG_CLK_RATE		32000
#define QG_ACTUAL_CLK_RATE	32764
int get_sample_interval(struct qpnp_qg *chip, u32 *sample_interval)
{
	int rc;
@@ -181,6 +191,11 @@ int get_sample_interval(struct qpnp_qg *chip, u32 *sample_interval)

	*sample_interval = reg * 10;

	if (chip->wa_flags & QG_CLK_ADJUST_WA) {
		*sample_interval = DIV_ROUND_CLOSEST(
			*sample_interval * QG_CLK_RATE, QG_ACTUAL_CLK_RATE);
	}

	return rc;
}

@@ -354,7 +369,7 @@ int qg_get_battery_current(struct qpnp_qg *chip, int *ibat_ua)
	}

	last_ibat = sign_extend32(last_ibat, 15);
	*ibat_ua = I_RAW_TO_UA(last_ibat);
	*ibat_ua = qg_iraw_to_ua(chip, last_ibat);

release:
	/* release */
+1 −0
Original line number Diff line number Diff line
@@ -27,5 +27,6 @@ int qg_write_monotonic_soc(struct qpnp_qg *chip, int msoc);
int qg_get_battery_temp(struct qpnp_qg *chip, int *batt_temp);
int qg_get_battery_current(struct qpnp_qg *chip, int *ibat_ua);
int qg_get_battery_voltage(struct qpnp_qg *chip, int *vbat_uv);
s64 qg_iraw_to_ua(struct qpnp_qg *chip, int iraw);

#endif
Loading