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

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

Merge "qpnp-fg-gen3: expose a fake battery SOC for debug board"

parents 2300a2a8 e5f967c5
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -222,7 +222,6 @@ struct fg_batt_props {
	int		float_volt_uv;
	int		vbatt_full_mv;
	int		fastchg_curr_ma;
	int		batt_id_kohm;
};

struct fg_cyc_ctr_data {
@@ -278,7 +277,7 @@ struct fg_chip {
	u32			batt_soc_base;
	u32			batt_info_base;
	u32			mem_if_base;
	int			batt_id;
	int			batt_id_kohms;
	int			status;
	int			charge_done;
	int			last_soc;
+26 −2
Original line number Diff line number Diff line
@@ -655,12 +655,36 @@ static int fg_get_msoc_raw(struct fg_chip *chip, int *val)
	return 0;
}

#define DEBUG_BATT_ID_KOHMS	7
static bool is_debug_batt_id(struct fg_chip *chip)
{
	int batt_id_delta = 0;

	if (!chip->batt_id_kohms)
		return false;

	batt_id_delta = abs(chip->batt_id_kohms - DEBUG_BATT_ID_KOHMS);
	if (batt_id_delta <= 1) {
		fg_dbg(chip, FG_POWER_SUPPLY, "Debug battery id: %dKohms\n",
			chip->batt_id_kohms);
		return true;
	}

	return false;
}

#define FULL_CAPACITY	100
#define FULL_SOC_RAW	255
#define DEBUG_BATT_SOC	67
static int fg_get_prop_capacity(struct fg_chip *chip, int *val)
{
	int rc, msoc;

	if (is_debug_batt_id(chip)) {
		*val = DEBUG_BATT_SOC;
		return 0;
	}

	if (chip->charge_full) {
		*val = FULL_CAPACITY;
		return 0;
@@ -725,7 +749,7 @@ static int fg_get_batt_profile(struct fg_chip *chip)
	}

	batt_id /= 1000;
	chip->batt_id = batt_id;
	chip->batt_id_kohms = batt_id;
	batt_node = of_find_node_by_name(node, "qcom,battery-data");
	if (!batt_node) {
		pr_err("Batterydata not available\n");
@@ -2612,7 +2636,7 @@ static int fg_parse_dt(struct fg_chip *chip)
	rc = fg_get_batt_profile(chip);
	if (rc < 0)
		pr_warn("profile for batt_id=%dKOhms not found..using OTP, rc:%d\n",
			chip->batt_id, rc);
			chip->batt_id_kohms, rc);

	/* Read all the optional properties below */
	rc = of_property_read_u32(node, "qcom,fg-cutoff-voltage", &temp);