Commit e1468202 authored by Simon Trimmer's avatar Simon Trimmer Committed by Mark Brown

ASoC: wm_adsp: Split out struct cs_dsp from struct wm_adsp

In preparation for moving the generic DSP support out of ASoC split
struct wm_adsp into two parts, one will form the structure for the new
generic DSP code and embed that one into wm_adsp.
Signed-off-by: default avatarSimon Trimmer <simont@opensource.cirrus.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210913160057.103842-15-simont@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent a828056f
......@@ -1402,17 +1402,17 @@ static int cs47l15_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "Failed to set DSP IRQ wake: %d\n", ret);
cs47l15->core.adsp[0].part = "cs47l15";
cs47l15->core.adsp[0].num = 1;
cs47l15->core.adsp[0].type = WMFW_ADSP2;
cs47l15->core.adsp[0].rev = 2;
cs47l15->core.adsp[0].dev = madera->dev;
cs47l15->core.adsp[0].regmap = madera->regmap_32bit;
cs47l15->core.adsp[0].cs_dsp.num = 1;
cs47l15->core.adsp[0].cs_dsp.type = WMFW_ADSP2;
cs47l15->core.adsp[0].cs_dsp.rev = 2;
cs47l15->core.adsp[0].cs_dsp.dev = madera->dev;
cs47l15->core.adsp[0].cs_dsp.regmap = madera->regmap_32bit;
cs47l15->core.adsp[0].base = MADERA_DSP1_CONFIG_1;
cs47l15->core.adsp[0].mem = cs47l15_dsp1_regions;
cs47l15->core.adsp[0].num_mems = ARRAY_SIZE(cs47l15_dsp1_regions);
cs47l15->core.adsp[0].cs_dsp.base = MADERA_DSP1_CONFIG_1;
cs47l15->core.adsp[0].cs_dsp.mem = cs47l15_dsp1_regions;
cs47l15->core.adsp[0].cs_dsp.num_mems = ARRAY_SIZE(cs47l15_dsp1_regions);
cs47l15->core.adsp[0].lock_regions =
cs47l15->core.adsp[0].cs_dsp.lock_regions =
CS_ADSP2_REGION_1 | CS_ADSP2_REGION_2 | CS_ADSP2_REGION_3;
ret = wm_adsp2_init(&cs47l15->core.adsp[0]);
......
......@@ -1234,15 +1234,15 @@ static int cs47l24_probe(struct platform_device *pdev)
for (i = 1; i <= 2; i++) {
cs47l24->core.adsp[i].part = "cs47l24";
cs47l24->core.adsp[i].num = i + 1;
cs47l24->core.adsp[i].type = WMFW_ADSP2;
cs47l24->core.adsp[i].dev = arizona->dev;
cs47l24->core.adsp[i].regmap = arizona->regmap;
cs47l24->core.adsp[i].cs_dsp.num = i + 1;
cs47l24->core.adsp[i].cs_dsp.type = WMFW_ADSP2;
cs47l24->core.adsp[i].cs_dsp.dev = arizona->dev;
cs47l24->core.adsp[i].cs_dsp.regmap = arizona->regmap;
cs47l24->core.adsp[i].base = ARIZONA_DSP1_CONTROL_1 +
cs47l24->core.adsp[i].cs_dsp.base = ARIZONA_DSP1_CONTROL_1 +
(0x100 * i);
cs47l24->core.adsp[i].mem = cs47l24_dsp_regions[i - 1];
cs47l24->core.adsp[i].num_mems =
cs47l24->core.adsp[i].cs_dsp.mem = cs47l24_dsp_regions[i - 1];
cs47l24->core.adsp[i].cs_dsp.num_mems =
ARRAY_SIZE(cs47l24_dsp2_regions);
ret = wm_adsp2_init(&cs47l24->core.adsp[i]);
......
......@@ -1686,15 +1686,15 @@ static int cs47l35_probe(struct platform_device *pdev)
for (i = 0; i < CS47L35_NUM_ADSP; i++) {
cs47l35->core.adsp[i].part = "cs47l35";
cs47l35->core.adsp[i].num = i + 1;
cs47l35->core.adsp[i].type = WMFW_ADSP2;
cs47l35->core.adsp[i].rev = 1;
cs47l35->core.adsp[i].dev = madera->dev;
cs47l35->core.adsp[i].regmap = madera->regmap_32bit;
cs47l35->core.adsp[i].base = wm_adsp2_control_bases[i];
cs47l35->core.adsp[i].mem = cs47l35_dsp_regions[i];
cs47l35->core.adsp[i].num_mems =
cs47l35->core.adsp[i].cs_dsp.num = i + 1;
cs47l35->core.adsp[i].cs_dsp.type = WMFW_ADSP2;
cs47l35->core.adsp[i].cs_dsp.rev = 1;
cs47l35->core.adsp[i].cs_dsp.dev = madera->dev;
cs47l35->core.adsp[i].cs_dsp.regmap = madera->regmap_32bit;
cs47l35->core.adsp[i].cs_dsp.base = wm_adsp2_control_bases[i];
cs47l35->core.adsp[i].cs_dsp.mem = cs47l35_dsp_regions[i];
cs47l35->core.adsp[i].cs_dsp.num_mems =
ARRAY_SIZE(cs47l35_dsp1_regions);
ret = wm_adsp2_init(&cs47l35->core.adsp[i]);
......
......@@ -2632,15 +2632,15 @@ static int cs47l85_probe(struct platform_device *pdev)
for (i = 0; i < CS47L85_NUM_ADSP; i++) {
cs47l85->core.adsp[i].part = "cs47l85";
cs47l85->core.adsp[i].num = i + 1;
cs47l85->core.adsp[i].type = WMFW_ADSP2;
cs47l85->core.adsp[i].rev = 1;
cs47l85->core.adsp[i].dev = madera->dev;
cs47l85->core.adsp[i].regmap = madera->regmap_32bit;
cs47l85->core.adsp[i].base = wm_adsp2_control_bases[i];
cs47l85->core.adsp[i].mem = cs47l85_dsp_regions[i];
cs47l85->core.adsp[i].num_mems =
cs47l85->core.adsp[i].cs_dsp.num = i + 1;
cs47l85->core.adsp[i].cs_dsp.type = WMFW_ADSP2;
cs47l85->core.adsp[i].cs_dsp.rev = 1;
cs47l85->core.adsp[i].cs_dsp.dev = madera->dev;
cs47l85->core.adsp[i].cs_dsp.regmap = madera->regmap_32bit;
cs47l85->core.adsp[i].cs_dsp.base = wm_adsp2_control_bases[i];
cs47l85->core.adsp[i].cs_dsp.mem = cs47l85_dsp_regions[i];
cs47l85->core.adsp[i].cs_dsp.num_mems =
ARRAY_SIZE(cs47l85_dsp1_regions);
ret = wm_adsp2_init(&cs47l85->core.adsp[i]);
......
......@@ -2543,18 +2543,18 @@ static int cs47l90_probe(struct platform_device *pdev)
for (i = 0; i < CS47L90_NUM_ADSP; i++) {
cs47l90->core.adsp[i].part = "cs47l90";
cs47l90->core.adsp[i].num = i + 1;
cs47l90->core.adsp[i].type = WMFW_ADSP2;
cs47l90->core.adsp[i].rev = 2;
cs47l90->core.adsp[i].dev = madera->dev;
cs47l90->core.adsp[i].regmap = madera->regmap_32bit;
cs47l90->core.adsp[i].base = cs47l90_dsp_control_bases[i];
cs47l90->core.adsp[i].mem = cs47l90_dsp_regions[i];
cs47l90->core.adsp[i].num_mems =
cs47l90->core.adsp[i].cs_dsp.num = i + 1;
cs47l90->core.adsp[i].cs_dsp.type = WMFW_ADSP2;
cs47l90->core.adsp[i].cs_dsp.rev = 2;
cs47l90->core.adsp[i].cs_dsp.dev = madera->dev;
cs47l90->core.adsp[i].cs_dsp.regmap = madera->regmap_32bit;
cs47l90->core.adsp[i].cs_dsp.base = cs47l90_dsp_control_bases[i];
cs47l90->core.adsp[i].cs_dsp.mem = cs47l90_dsp_regions[i];
cs47l90->core.adsp[i].cs_dsp.num_mems =
ARRAY_SIZE(cs47l90_dsp1_regions);
cs47l90->core.adsp[i].lock_regions = CS_ADSP2_REGION_1_9;
cs47l90->core.adsp[i].cs_dsp.lock_regions = CS_ADSP2_REGION_1_9;
ret = wm_adsp2_init(&cs47l90->core.adsp[i]);
......
......@@ -2002,17 +2002,17 @@ static int cs47l92_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "Failed to set DSP IRQ wake: %d\n", ret);
cs47l92->core.adsp[0].part = "cs47l92";
cs47l92->core.adsp[0].num = 1;
cs47l92->core.adsp[0].type = WMFW_ADSP2;
cs47l92->core.adsp[0].rev = 2;
cs47l92->core.adsp[0].dev = madera->dev;
cs47l92->core.adsp[0].regmap = madera->regmap_32bit;
cs47l92->core.adsp[0].cs_dsp.num = 1;
cs47l92->core.adsp[0].cs_dsp.type = WMFW_ADSP2;
cs47l92->core.adsp[0].cs_dsp.rev = 2;
cs47l92->core.adsp[0].cs_dsp.dev = madera->dev;
cs47l92->core.adsp[0].cs_dsp.regmap = madera->regmap_32bit;
cs47l92->core.adsp[0].base = MADERA_DSP1_CONFIG_1;
cs47l92->core.adsp[0].mem = cs47l92_dsp1_regions;
cs47l92->core.adsp[0].num_mems = ARRAY_SIZE(cs47l92_dsp1_regions);
cs47l92->core.adsp[0].cs_dsp.base = MADERA_DSP1_CONFIG_1;
cs47l92->core.adsp[0].cs_dsp.mem = cs47l92_dsp1_regions;
cs47l92->core.adsp[0].cs_dsp.num_mems = ARRAY_SIZE(cs47l92_dsp1_regions);
cs47l92->core.adsp[0].lock_regions = CS_ADSP2_REGION_1_9;
cs47l92->core.adsp[0].cs_dsp.lock_regions = CS_ADSP2_REGION_1_9;
ret = wm_adsp2_init(&cs47l92->core.adsp[0]);
if (ret != 0)
......
......@@ -905,7 +905,7 @@ static int madera_adsp_rate_put(struct snd_kcontrol *kcontrol,
*/
mutex_lock(&priv->rate_lock);
if (!madera_can_change_grp_rate(priv, priv->adsp[adsp_num].base)) {
if (!madera_can_change_grp_rate(priv, priv->adsp[adsp_num].cs_dsp.base)) {
dev_warn(priv->madera->dev,
"Cannot change '%s' while in use by active audio paths\n",
kcontrol->id.name);
......@@ -964,7 +964,7 @@ static int madera_write_adsp_clk_setting(struct madera_priv *priv,
unsigned int mask = MADERA_DSP_RATE_MASK;
int ret;
val = priv->adsp_rate_cache[dsp->num - 1] << MADERA_DSP_RATE_SHIFT;
val = priv->adsp_rate_cache[dsp->cs_dsp.num - 1] << MADERA_DSP_RATE_SHIFT;
switch (priv->madera->type) {
case CS47L35:
......@@ -978,15 +978,15 @@ static int madera_write_adsp_clk_setting(struct madera_priv *priv,
/* Configure exact dsp frequency */
dev_dbg(priv->madera->dev, "Set DSP frequency to 0x%x\n", freq);
ret = regmap_write(dsp->regmap,
dsp->base + MADERA_DSP_CONFIG_2_OFFS, freq);
ret = regmap_write(dsp->cs_dsp.regmap,
dsp->cs_dsp.base + MADERA_DSP_CONFIG_2_OFFS, freq);
if (ret)
goto err;
break;
}
ret = regmap_update_bits(dsp->regmap,
dsp->base + MADERA_DSP_CONFIG_1_OFFS,
ret = regmap_update_bits(dsp->cs_dsp.regmap,
dsp->cs_dsp.base + MADERA_DSP_CONFIG_1_OFFS,
mask, val);
if (ret)
goto err;
......@@ -996,7 +996,7 @@ static int madera_write_adsp_clk_setting(struct madera_priv *priv,
return 0;
err:
dev_err(dsp->dev, "Failed to set DSP%d clock: %d\n", dsp->num, ret);
dev_err(dsp->cs_dsp.dev, "Failed to set DSP%d clock: %d\n", dsp->cs_dsp.num, ret);
return ret;
}
......@@ -1018,7 +1018,7 @@ int madera_set_adsp_clk(struct madera_priv *priv, int dsp_num,
* changes are locked out by the domain_group_ref reference count.
*/
ret = regmap_read(dsp->regmap, dsp->base, &cur);
ret = regmap_read(dsp->cs_dsp.regmap, dsp->cs_dsp.base, &cur);
if (ret) {
dev_err(madera->dev,
"Failed to read current DSP rate: %d\n", ret);
......@@ -1027,7 +1027,7 @@ int madera_set_adsp_clk(struct madera_priv *priv, int dsp_num,
cur &= MADERA_DSP_RATE_MASK;
new = priv->adsp_rate_cache[dsp->num - 1] << MADERA_DSP_RATE_SHIFT;
new = priv->adsp_rate_cache[dsp->cs_dsp.num - 1] << MADERA_DSP_RATE_SHIFT;
if (new == cur) {
dev_dbg(madera->dev, "DSP rate not changed\n");
......
......@@ -2202,23 +2202,23 @@ static int wm2200_i2c_probe(struct i2c_client *i2c,
}
for (i = 0; i < 2; i++) {
wm2200->dsp[i].type = WMFW_ADSP1;
wm2200->dsp[i].cs_dsp.type = WMFW_ADSP1;
wm2200->dsp[i].part = "wm2200";
wm2200->dsp[i].num = i + 1;
wm2200->dsp[i].dev = &i2c->dev;
wm2200->dsp[i].regmap = wm2200->regmap;
wm2200->dsp[i].sysclk_reg = WM2200_CLOCKING_3;
wm2200->dsp[i].sysclk_mask = WM2200_SYSCLK_FREQ_MASK;
wm2200->dsp[i].sysclk_shift = WM2200_SYSCLK_FREQ_SHIFT;
wm2200->dsp[i].cs_dsp.num = i + 1;
wm2200->dsp[i].cs_dsp.dev = &i2c->dev;
wm2200->dsp[i].cs_dsp.regmap = wm2200->regmap;
wm2200->dsp[i].cs_dsp.sysclk_reg = WM2200_CLOCKING_3;
wm2200->dsp[i].cs_dsp.sysclk_mask = WM2200_SYSCLK_FREQ_MASK;
wm2200->dsp[i].cs_dsp.sysclk_shift = WM2200_SYSCLK_FREQ_SHIFT;
}
wm2200->dsp[0].base = WM2200_DSP1_CONTROL_1;
wm2200->dsp[0].mem = wm2200_dsp1_regions;
wm2200->dsp[0].num_mems = ARRAY_SIZE(wm2200_dsp1_regions);
wm2200->dsp[0].cs_dsp.base = WM2200_DSP1_CONTROL_1;
wm2200->dsp[0].cs_dsp.mem = wm2200_dsp1_regions;
wm2200->dsp[0].cs_dsp.num_mems = ARRAY_SIZE(wm2200_dsp1_regions);
wm2200->dsp[1].base = WM2200_DSP2_CONTROL_1;
wm2200->dsp[1].mem = wm2200_dsp2_regions;
wm2200->dsp[1].num_mems = ARRAY_SIZE(wm2200_dsp2_regions);
wm2200->dsp[1].cs_dsp.base = WM2200_DSP2_CONTROL_1;
wm2200->dsp[1].cs_dsp.mem = wm2200_dsp2_regions;
wm2200->dsp[1].cs_dsp.num_mems = ARRAY_SIZE(wm2200_dsp2_regions);
for (i = 0; i < ARRAY_SIZE(wm2200->dsp); i++)
wm_adsp1_init(&wm2200->dsp[i]);
......
......@@ -2046,13 +2046,13 @@ static int wm5102_probe(struct platform_device *pdev)
arizona_init_dvfs(&wm5102->core);
wm5102->core.adsp[0].part = "wm5102";
wm5102->core.adsp[0].num = 1;
wm5102->core.adsp[0].type = WMFW_ADSP2;
wm5102->core.adsp[0].base = ARIZONA_DSP1_CONTROL_1;
wm5102->core.adsp[0].dev = arizona->dev;
wm5102->core.adsp[0].regmap = arizona->regmap;
wm5102->core.adsp[0].mem = wm5102_dsp1_regions;
wm5102->core.adsp[0].num_mems = ARRAY_SIZE(wm5102_dsp1_regions);
wm5102->core.adsp[0].cs_dsp.num = 1;
wm5102->core.adsp[0].cs_dsp.type = WMFW_ADSP2;
wm5102->core.adsp[0].cs_dsp.base = ARIZONA_DSP1_CONTROL_1;
wm5102->core.adsp[0].cs_dsp.dev = arizona->dev;
wm5102->core.adsp[0].cs_dsp.regmap = arizona->regmap;
wm5102->core.adsp[0].cs_dsp.mem = wm5102_dsp1_regions;
wm5102->core.adsp[0].cs_dsp.num_mems = ARRAY_SIZE(wm5102_dsp1_regions);
ret = wm_adsp2_init(&wm5102->core.adsp[0]);
if (ret != 0)
......
......@@ -2409,15 +2409,15 @@ static int wm5110_probe(struct platform_device *pdev)
for (i = 0; i < WM5110_NUM_ADSP; i++) {
wm5110->core.adsp[i].part = "wm5110";
wm5110->core.adsp[i].num = i + 1;
wm5110->core.adsp[i].type = WMFW_ADSP2;
wm5110->core.adsp[i].dev = arizona->dev;
wm5110->core.adsp[i].regmap = arizona->regmap;
wm5110->core.adsp[i].cs_dsp.num = i + 1;
wm5110->core.adsp[i].cs_dsp.type = WMFW_ADSP2;
wm5110->core.adsp[i].cs_dsp.dev = arizona->dev;
wm5110->core.adsp[i].cs_dsp.regmap = arizona->regmap;
wm5110->core.adsp[i].base = ARIZONA_DSP1_CONTROL_1
wm5110->core.adsp[i].cs_dsp.base = ARIZONA_DSP1_CONTROL_1
+ (0x100 * i);
wm5110->core.adsp[i].mem = wm5110_dsp_regions[i];
wm5110->core.adsp[i].num_mems
wm5110->core.adsp[i].cs_dsp.mem = wm5110_dsp_regions[i];
wm5110->core.adsp[i].cs_dsp.num_mems
= ARRAY_SIZE(wm5110_dsp1_regions);
ret = wm_adsp2_init(&wm5110->core.adsp[i]);
......
This diff is collapsed.
......@@ -49,7 +49,6 @@ struct cs_dsp_alg_region {
unsigned int base;
};
struct wm_adsp;
struct wm_adsp_compr;
struct wm_adsp_compr_buf;
struct cs_dsp_ops;
......@@ -60,7 +59,7 @@ struct cs_dsp_coeff_ctl {
const char *subname;
unsigned int subname_len;
struct cs_dsp_alg_region alg_region;
struct wm_adsp *dsp;
struct cs_dsp *dsp;
unsigned int enabled:1;
struct list_head list;
void *cache;
......@@ -73,16 +72,13 @@ struct cs_dsp_coeff_ctl {
void *priv;
};
struct wm_adsp {
const char *part;
struct cs_dsp {
const char *name;
const char *fwf_name;
int rev;
int num;
int type;
struct device *dev;
struct regmap *regmap;
struct snd_soc_component *component;
const struct cs_dsp_ops *ops;
......@@ -102,23 +98,13 @@ struct wm_adsp {
const struct cs_dsp_region *mem;
int num_mems;
unsigned int sys_config_size;
int fw;
int fw_ver;
bool preloaded;
bool booted;
bool running;
bool fatal_error;
struct list_head ctl_list;
struct work_struct boot_work;
struct list_head compr_list;
struct list_head buffer_list;
struct mutex pwr_lock;
unsigned int lock_regions;
......@@ -128,31 +114,49 @@ struct wm_adsp {
char *wmfw_file_name;
char *bin_file_name;
#endif
};
struct wm_adsp {
struct cs_dsp cs_dsp;
const char *part;
const char *fwf_name;
struct snd_soc_component *component;
unsigned int sys_config_size;
int fw;
struct work_struct boot_work;
bool preloaded;
bool fatal_error;
struct list_head compr_list;
struct list_head buffer_list;
};
struct cs_dsp_ops {
bool (*validate_version)(struct wm_adsp *dsp, unsigned int version);
unsigned int (*parse_sizes)(struct wm_adsp *dsp,
bool (*validate_version)(struct cs_dsp *dsp, unsigned int version);
unsigned int (*parse_sizes)(struct cs_dsp *dsp,
const char * const file,
unsigned int pos,
const struct firmware *firmware);
int (*setup_algs)(struct wm_adsp *dsp);
int (*setup_algs)(struct cs_dsp *dsp);
unsigned int (*region_to_reg)(struct cs_dsp_region const *mem,
unsigned int offset);
void (*show_fw_status)(struct wm_adsp *dsp);
void (*stop_watchdog)(struct wm_adsp *dsp);
void (*show_fw_status)(struct cs_dsp *dsp);
void (*stop_watchdog)(struct cs_dsp *dsp);
int (*enable_memory)(struct wm_adsp *dsp);
void (*disable_memory)(struct wm_adsp *dsp);
int (*lock_memory)(struct wm_adsp *dsp, unsigned int lock_regions);
int (*enable_memory)(struct cs_dsp *dsp);
void (*disable_memory)(struct cs_dsp *dsp);
int (*lock_memory)(struct cs_dsp *dsp, unsigned int lock_regions);
int (*enable_core)(struct wm_adsp *dsp);
void (*disable_core)(struct wm_adsp *dsp);
int (*enable_core)(struct cs_dsp *dsp);
void (*disable_core)(struct cs_dsp *dsp);
int (*start_core)(struct wm_adsp *dsp);
void (*stop_core)(struct wm_adsp *dsp);
int (*start_core)(struct cs_dsp *dsp);
void (*stop_core)(struct cs_dsp *dsp);
};
#define WM_ADSP1(wname, num) \
......
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