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

Commit 63d486e8 authored by Ashay Jaiswal's avatar Ashay Jaiswal Committed by Harry Yang
Browse files

qpnp-fg-gen3: Add support for PMFALCON in Fuel Gauge



Add support of PMFALCON PMIC in FG driver. PMFALCON
FG core uses same SRAM map as PMI8998v2.0.
While at it, add workaround flag variable to keep track
of all hardware specific workarounds.

CRs-Fixed: 1096793
Change-Id: I8ba73276fd30f6eaf935ed77b75601f1322c0ba6
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent 15dc0c88
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -188,6 +188,10 @@ struct fg_alg_flag {
	bool	invalid;
};

enum wa_flags {
	PMI8998_V1_REV_WA = BIT(0),
};

/* DT parameters for FG device */
struct fg_dt_props {
	bool	force_load_profile;
@@ -306,6 +310,7 @@ struct fg_chip {
	u32			batt_soc_base;
	u32			batt_info_base;
	u32			mem_if_base;
	u32			wa_flags;
	int			batt_id_kohms;
	int			charge_status;
	int			prev_charge_status;
+12 −7
Original line number Diff line number Diff line
@@ -550,7 +550,7 @@ static int fg_get_battery_esr(struct fg_chip *chip, int *val)
		return rc;
	}

	if (chip->pmic_rev_id->rev4 < PMI8998_V2P0_REV4)
	if (chip->wa_flags & PMI8998_V1_REV_WA)
		temp = ((buf[0] & ESR_MSB_MASK) << 8) |
			(buf[1] & ESR_LSB_MASK);
	else
@@ -597,7 +597,7 @@ static int fg_get_battery_current(struct fg_chip *chip, int *val)
		return rc;
	}

	if (chip->pmic_rev_id->rev4 < PMI8998_V2P0_REV4)
	if (chip->wa_flags & PMI8998_V1_REV_WA)
		temp = buf[0] << 8 | buf[1];
	else
		temp = buf[1] << 8 | buf[0];
@@ -624,7 +624,7 @@ static int fg_get_battery_voltage(struct fg_chip *chip, int *val)
		return rc;
	}

	if (chip->pmic_rev_id->rev4 < PMI8998_V2P0_REV4)
	if (chip->wa_flags & PMI8998_V1_REV_WA)
		temp = buf[0] << 8 | buf[1];
	else
		temp = buf[1] << 8 | buf[0];
@@ -2401,7 +2401,7 @@ static int fg_hw_init(struct fg_chip *chip)
	}

	/* This SRAM register is only present in v2.0 and above */
	if (chip->pmic_rev_id->rev4 >= PMI8998_V2P0_REV4 &&
	if (!(chip->wa_flags & PMI8998_V1_REV_WA) &&
					chip->bp.float_volt_uv > 0) {
		fg_encode(chip->sp, FG_SRAM_FLOAT_VOLT,
			chip->bp.float_volt_uv / 1000, buf);
@@ -2482,7 +2482,7 @@ static int fg_hw_init(struct fg_chip *chip)
	}

	/* This configuration is available only for pmicobalt v2.0 and above */
	if (chip->pmic_rev_id->rev4 >= PMI8998_V2P0_REV4 &&
	if (!(chip->wa_flags & PMI8998_V1_REV_WA) &&
			chip->dt.recharge_volt_thr_mv > 0) {
		fg_encode(chip->sp, FG_SRAM_RECHARGE_VBATT_THR,
			chip->dt.recharge_volt_thr_mv, buf);
@@ -3013,6 +3013,7 @@ static int fg_parse_dt(struct fg_chip *chip)
		if (chip->pmic_rev_id->rev4 < PMI8998_V2P0_REV4) {
			chip->sp = pmi8998_v1_sram_params;
			chip->alg_flags = pmi8998_v1_alg_flags;
			chip->wa_flags |= PMI8998_V1_REV_WA;
		} else if (chip->pmic_rev_id->rev4 == PMI8998_V2P0_REV4) {
			chip->sp = pmi8998_v2_sram_params;
			chip->alg_flags = pmi8998_v2_alg_flags;
@@ -3020,6 +3021,10 @@ static int fg_parse_dt(struct fg_chip *chip)
			return -EINVAL;
		}
		break;
	case PMFALCON_SUBTYPE:
		chip->sp = pmi8998_v2_sram_params;
		chip->alg_flags = pmi8998_v2_alg_flags;
		break;
	default:
		return -EINVAL;
	}