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

Commit 3b393283 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen3: fg-util: Update dump_sram to support GEN4 FG



Currently, dump_sram is printing the addresses incrementing by 1.
This is fine for GEN3 FG SRAM. However, this helper function will
be shared with GEN4 FG for which SRAM address will be incremented
by 2 as the print format to dump SRAM remains same i.e. 4 bytes
per line. Add support for it.

Change-Id: Id20c4338c4d9d14d36624b04da76bda8f24e9692
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 8aa0accf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -506,7 +506,7 @@ extern int fg_clear_ima_errors_if_any(struct fg_dev *fg, bool check_hw_sts);
extern int fg_clear_dma_errors_if_any(struct fg_dev *fg);
extern int fg_debugfs_create(struct fg_dev *fg);
extern void fill_string(char *str, size_t str_len, u8 *buf, int buf_len);
extern void dump_sram(u8 *buf, int addr, int len);
extern void dump_sram(struct fg_dev *fg, u8 *buf, int addr, int len);
extern s64 fg_float_decode(u16 val);
extern bool usb_psy_initialized(struct fg_dev *fg);
extern bool dc_psy_initialized(struct fg_dev *fg);
+16 −6
Original line number Diff line number Diff line
@@ -459,21 +459,31 @@ void fill_string(char *str, size_t str_len, u8 *buf, int buf_len)
	}
}

void dump_sram(u8 *buf, int addr, int len)
void dump_sram(struct fg_dev *fg, u8 *buf, int addr, int len)
{
	int i;
	char str[16];

	/*
	 * Length passed should be in multiple of 4 as each FG SRAM word
	 * holds 4 bytes. To keep this simple, even if a length which is
	 * not a multiple of 4 bytes or less than 4 bytes is passed, SRAM
	 * registers dumped will be always in multiple of 4 bytes.
	 * Length passed should be in multiple of 4 as each GEN3 FG SRAM word
	 * holds 4 bytes and GEN4 FG SRAM word holds 2 bytes. To keep this
	 * simple, even if a length which is not a multiple of 4 bytes or less
	 * than 4 bytes is passed, SRAM registers dumped will be always in
	 * multiple of 4 bytes.
	 */
	for (i = 0; i < len; i += 4) {
		str[0] = '\0';
		fill_string(str, sizeof(str), buf + i, 4);

		/*
		 * We still print 4 bytes per line. However, the address
		 * should be incremented by 2 for GEN4 FG as each word holds
		 * 2 bytes.
		 */
		if (fg->version == GEN3_FG)
			pr_info("%03d %s\n", addr + (i / 4), str);
		else
			pr_info("%03d %s\n", addr + (i / 2), str);
	}
}

+5 −5
Original line number Diff line number Diff line
@@ -2361,11 +2361,11 @@ static bool is_profile_load_required(struct fg_dev *fg)
			pr_warn("Profiles doesn't match, skipping loading it since force_load_profile is disabled\n");
			if (fg_profile_dump) {
				pr_info("FG: loaded profile:\n");
				dump_sram(buf, PROFILE_LOAD_WORD,
				dump_sram(fg, buf, PROFILE_LOAD_WORD,
					PROFILE_COMP_LEN);
				pr_info("FG: available profile:\n");
				dump_sram(chip->batt_profile, PROFILE_LOAD_WORD,
					PROFILE_LEN);
				dump_sram(fg, chip->batt_profile,
					PROFILE_LOAD_WORD, PROFILE_LEN);
			}
			fg->profile_load_status = PROFILE_SKIPPED;
			return false;
@@ -2376,7 +2376,7 @@ static bool is_profile_load_required(struct fg_dev *fg)
		fg_dbg(fg, FG_STATUS, "Profile integrity bit is not set\n");
		if (fg_profile_dump) {
			pr_info("FG: profile to be loaded:\n");
			dump_sram(chip->batt_profile, PROFILE_LOAD_WORD,
			dump_sram(fg, chip->batt_profile, PROFILE_LOAD_WORD,
				PROFILE_LEN);
		}
	}
@@ -2582,7 +2582,7 @@ static void sram_dump_work(struct work_struct *work)
	quotient = div_s64_rem(timestamp_ms, 1000, &remainder);
	fg_dbg(fg, FG_STATUS, "SRAM Dump Started at %lld.%d\n",
		quotient, remainder);
	dump_sram(buf, 0, FG_SRAM_LEN);
	dump_sram(fg, buf, 0, FG_SRAM_LEN);
	timestamp_ms = ktime_to_ms(ktime_get_boottime());
	quotient = div_s64_rem(timestamp_ms, 1000, &remainder);
	fg_dbg(fg, FG_STATUS, "SRAM Dump done at %lld.%d\n",