Commit 4049ce86 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: wm_adsp: Refactor firmware status reading

In preparation for further additions refactor the reading of the
firmware status.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b9070df4
...@@ -788,49 +788,42 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem, ...@@ -788,49 +788,42 @@ static unsigned int wm_adsp_region_to_reg(struct wm_adsp_region const *mem,
} }
} }
static void wm_adsp2_show_fw_status(struct wm_adsp *dsp) static void wm_adsp_read_fw_status(struct wm_adsp *dsp,
int noffs, unsigned int *offs)
{ {
unsigned int scratch[4];
unsigned int addr = dsp->base + ADSP2_SCRATCH0;
unsigned int i; unsigned int i;
int ret; int ret;
for (i = 0; i < ARRAY_SIZE(scratch); ++i) { for (i = 0; i < noffs; ++i) {
ret = regmap_read(dsp->regmap, addr + i, &scratch[i]); ret = regmap_read(dsp->regmap, dsp->base + offs[i], &offs[i]);
if (ret) { if (ret) {
adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret); adsp_err(dsp, "Failed to read SCRATCH%u: %d\n", i, ret);
return; return;
} }
} }
}
static void wm_adsp2_show_fw_status(struct wm_adsp *dsp)
{
unsigned int offs[] = {
ADSP2_SCRATCH0, ADSP2_SCRATCH1, ADSP2_SCRATCH2, ADSP2_SCRATCH3,
};
wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs);
adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n",
scratch[0], scratch[1], scratch[2], scratch[3]); offs[0], offs[1], offs[2], offs[3]);
} }
static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp) static void wm_adsp2v2_show_fw_status(struct wm_adsp *dsp)
{ {
unsigned int scratch[2]; unsigned int offs[] = { ADSP2V2_SCRATCH0_1, ADSP2V2_SCRATCH2_3 };
int ret;
ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH0_1, wm_adsp_read_fw_status(dsp, ARRAY_SIZE(offs), offs);
&scratch[0]);
if (ret) {
adsp_err(dsp, "Failed to read SCRATCH0_1: %d\n", ret);
return;
}
ret = regmap_read(dsp->regmap, dsp->base + ADSP2V2_SCRATCH2_3,
&scratch[1]);
if (ret) {
adsp_err(dsp, "Failed to read SCRATCH2_3: %d\n", ret);
return;
}
adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n", adsp_dbg(dsp, "FW SCRATCH 0:0x%x 1:0x%x 2:0x%x 3:0x%x\n",
scratch[0] & 0xFFFF, offs[0] & 0xFFFF, offs[0] >> 16,
scratch[0] >> 16, offs[1] & 0xFFFF, offs[1] >> 16);
scratch[1] & 0xFFFF,
scratch[1] >> 16);
} }
static inline struct wm_coeff_ctl *bytes_ext_to_ctl(struct soc_bytes_ext *ext) static inline struct wm_coeff_ctl *bytes_ext_to_ctl(struct soc_bytes_ext *ext)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment