Commit b9070df4 authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

ASoC: wm_adsp: Move wm_adsp2_set_dspclk to CODEC drivers

The original wm_adsp2_early_event took an additional frequency
argument for clocking control so could not be used directly as a
DAPM callback. But this setup could equally be done by the codec
driver function wrapping wm_adsp2_early event. In preparation
for adding support for new core types wm_adsp2_set_dspclk has
been exported, and the freq argument removed so that it can
be used directly as a DAPM callback.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2b0ee49f
...@@ -75,7 +75,9 @@ static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w, ...@@ -75,7 +75,9 @@ static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w,
v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT; v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT;
return wm_adsp2_early_event(w, kcontrol, event, v); wm_adsp2_set_dspclk(w, v);
return wm_adsp2_early_event(w, kcontrol, event);
} }
static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
......
...@@ -646,6 +646,8 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, ...@@ -646,6 +646,8 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,
return ret; return ret;
} }
} }
wm_adsp2_set_dspclk(w, v);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
...@@ -659,7 +661,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, ...@@ -659,7 +661,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w,
break; break;
} }
return wm_adsp2_early_event(w, kcontrol, event, v); return wm_adsp2_early_event(w, kcontrol, event);
} }
static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol,
......
...@@ -211,7 +211,9 @@ static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w, ...@@ -211,7 +211,9 @@ static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w,
v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT; v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT;
return wm_adsp2_early_event(w, kcontrol, event, v); wm_adsp2_set_dspclk(w, v);
return wm_adsp2_early_event(w, kcontrol, event);
} }
static const struct reg_sequence wm5110_no_dre_left_enable[] = { static const struct reg_sequence wm5110_no_dre_left_enable[] = {
......
...@@ -2715,26 +2715,22 @@ static void wm_adsp2_boot_work(struct work_struct *work) ...@@ -2715,26 +2715,22 @@ static void wm_adsp2_boot_work(struct work_struct *work)
mutex_unlock(&dsp->pwr_lock); mutex_unlock(&dsp->pwr_lock);
} }
static void wm_adsp2_set_dspclk(struct wm_adsp *dsp, unsigned int freq) int wm_adsp2_set_dspclk(struct snd_soc_dapm_widget *w, unsigned int freq)
{ {
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm_adsp *dsps = snd_soc_component_get_drvdata(component);
struct wm_adsp *dsp = &dsps[w->shift];
int ret; int ret;
switch (dsp->rev) { ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CLOCKING,
case 0: ADSP2_CLK_SEL_MASK,
ret = regmap_update_bits_async(dsp->regmap, freq << ADSP2_CLK_SEL_SHIFT);
dsp->base + ADSP2_CLOCKING, if (ret)
ADSP2_CLK_SEL_MASK, adsp_err(dsp, "Failed to set clock rate: %d\n", ret);
freq << ADSP2_CLK_SEL_SHIFT);
if (ret) { return ret;
adsp_err(dsp, "Failed to set clock rate: %d\n", ret);
return;
}
break;
default:
/* clock is handled by parent codec driver */
break;
}
} }
EXPORT_SYMBOL_GPL(wm_adsp2_set_dspclk);
int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol, int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
...@@ -2792,8 +2788,7 @@ static void wm_adsp_stop_watchdog(struct wm_adsp *dsp) ...@@ -2792,8 +2788,7 @@ static void wm_adsp_stop_watchdog(struct wm_adsp *dsp)
} }
int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event, struct snd_kcontrol *kcontrol, int event)
unsigned int freq)
{ {
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsps = snd_soc_component_get_drvdata(component);
...@@ -2802,7 +2797,6 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, ...@@ -2802,7 +2797,6 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
wm_adsp2_set_dspclk(dsp, freq);
queue_work(system_unbound_wq, &dsp->boot_work); queue_work(system_unbound_wq, &dsp->boot_work);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
......
...@@ -137,15 +137,17 @@ int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *comp ...@@ -137,15 +137,17 @@ int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *comp
int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component); int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component);
int wm_adsp1_event(struct snd_soc_dapm_widget *w, int wm_adsp1_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event); struct snd_kcontrol *kcontrol, int event);
int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, int wm_adsp2_early_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event, struct snd_kcontrol *kcontrol, int event);
unsigned int freq);
irqreturn_t wm_adsp2_bus_error(struct wm_adsp *adsp); irqreturn_t wm_adsp2_bus_error(struct wm_adsp *adsp);
int wm_adsp2_event(struct snd_soc_dapm_widget *w, int wm_adsp2_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event); struct snd_kcontrol *kcontrol, int event);
int wm_adsp2_set_dspclk(struct snd_soc_dapm_widget *w, unsigned int freq);
int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol, int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol); struct snd_ctl_elem_value *ucontrol);
int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol,
......
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