aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2016-09-20 08:52:32 -0400
committerMark Brown <broonie@kernel.org>2016-09-24 14:34:17 -0400
commit28823ebad5e73bd717ca820929de2d18415d9822 (patch)
tree9c9f95311f1e3bf6cc88b86a8049f476839c01c3
parent0f72a8a39cd033a26bddafe2b101d12cac039bdc (diff)
ASoC: wm_adsp: Separate concept of booted and running
Currently the wm_adsp driver has a flag that indicates the DSP is "running", this flag is used to gate access to the hardware. However this flag is actually set in the firmware download thread after the firmware has been downloaded, but this is before the core is actually started running, so really it currently indicates that the core has been booted and is perhaps running. This patch clearly separates out the concepts of booted (firmware is downloaded) and running (code is executing on the DSP) within the wm_adsp driver. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm_adsp.c36
-rw-r--r--sound/soc/codecs/wm_adsp.h2
2 files changed, 27 insertions, 11 deletions
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 21fbe7d07063..ae2f2b6e82ed 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -480,7 +480,7 @@ static ssize_t wm_adsp_debugfs_wmfw_read(struct file *file,
480 480
481 mutex_lock(&dsp->pwr_lock); 481 mutex_lock(&dsp->pwr_lock);
482 482
483 if (!dsp->wmfw_file_name || !dsp->running) 483 if (!dsp->wmfw_file_name || !dsp->booted)
484 ret = 0; 484 ret = 0;
485 else 485 else
486 ret = simple_read_from_buffer(user_buf, count, ppos, 486 ret = simple_read_from_buffer(user_buf, count, ppos,
@@ -500,7 +500,7 @@ static ssize_t wm_adsp_debugfs_bin_read(struct file *file,
500 500
501 mutex_lock(&dsp->pwr_lock); 501 mutex_lock(&dsp->pwr_lock);
502 502
503 if (!dsp->bin_file_name || !dsp->running) 503 if (!dsp->bin_file_name || !dsp->booted)
504 ret = 0; 504 ret = 0;
505 else 505 else
506 ret = simple_read_from_buffer(user_buf, count, ppos, 506 ret = simple_read_from_buffer(user_buf, count, ppos,
@@ -554,6 +554,9 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp,
554 if (!root) 554 if (!root)
555 goto err; 555 goto err;
556 556
557 if (!debugfs_create_bool("booted", S_IRUGO, root, &dsp->booted))
558 goto err;
559
557 if (!debugfs_create_bool("running", S_IRUGO, root, &dsp->running)) 560 if (!debugfs_create_bool("running", S_IRUGO, root, &dsp->running))
558 goto err; 561 goto err;
559 562
@@ -637,7 +640,7 @@ static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol,
637 640
638 mutex_lock(&dsp[e->shift_l].pwr_lock); 641 mutex_lock(&dsp[e->shift_l].pwr_lock);
639 642
640 if (dsp[e->shift_l].running || dsp[e->shift_l].compr) 643 if (dsp[e->shift_l].booted || dsp[e->shift_l].compr)
641 ret = -EBUSY; 644 ret = -EBUSY;
642 else 645 else
643 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0]; 646 dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0];
@@ -789,7 +792,7 @@ static int wm_coeff_put(struct snd_kcontrol *kctl,
789 memcpy(ctl->cache, p, ctl->len); 792 memcpy(ctl->cache, p, ctl->len);
790 793
791 ctl->set = 1; 794 ctl->set = 1;
792 if (ctl->enabled) 795 if (ctl->enabled && ctl->dsp->booted)
793 ret = wm_coeff_write_control(ctl, p, ctl->len); 796 ret = wm_coeff_write_control(ctl, p, ctl->len);
794 797
795 mutex_unlock(&ctl->dsp->pwr_lock); 798 mutex_unlock(&ctl->dsp->pwr_lock);
@@ -811,7 +814,7 @@ static int wm_coeff_tlv_put(struct snd_kcontrol *kctl,
811 ret = -EFAULT; 814 ret = -EFAULT;
812 } else { 815 } else {
813 ctl->set = 1; 816 ctl->set = 1;
814 if (ctl->enabled) 817 if (ctl->enabled && ctl->dsp->booted)
815 ret = wm_coeff_write_control(ctl, ctl->cache, size); 818 ret = wm_coeff_write_control(ctl, ctl->cache, size);
816 } 819 }
817 820
@@ -871,12 +874,12 @@ static int wm_coeff_get(struct snd_kcontrol *kctl,
871 mutex_lock(&ctl->dsp->pwr_lock); 874 mutex_lock(&ctl->dsp->pwr_lock);
872 875
873 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { 876 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
874 if (ctl->enabled) 877 if (ctl->enabled && ctl->dsp->booted)
875 ret = wm_coeff_read_control(ctl, p, ctl->len); 878 ret = wm_coeff_read_control(ctl, p, ctl->len);
876 else 879 else
877 ret = -EPERM; 880 ret = -EPERM;
878 } else { 881 } else {
879 if (!ctl->flags && ctl->enabled) 882 if (!ctl->flags && ctl->enabled && ctl->dsp->booted)
880 ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); 883 ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len);
881 884
882 memcpy(p, ctl->cache, ctl->len); 885 memcpy(p, ctl->cache, ctl->len);
@@ -898,12 +901,12 @@ static int wm_coeff_tlv_get(struct snd_kcontrol *kctl,
898 mutex_lock(&ctl->dsp->pwr_lock); 901 mutex_lock(&ctl->dsp->pwr_lock);
899 902
900 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) { 903 if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
901 if (ctl->enabled) 904 if (ctl->enabled && ctl->dsp->booted)
902 ret = wm_coeff_read_control(ctl, ctl->cache, size); 905 ret = wm_coeff_read_control(ctl, ctl->cache, size);
903 else 906 else
904 ret = -EPERM; 907 ret = -EPERM;
905 } else { 908 } else {
906 if (!ctl->flags && ctl->enabled) 909 if (!ctl->flags && ctl->enabled && ctl->dsp->booted)
907 ret = wm_coeff_read_control(ctl, ctl->cache, size); 910 ret = wm_coeff_read_control(ctl, ctl->cache, size);
908 } 911 }
909 912
@@ -2166,13 +2169,20 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
2166 if (ret != 0) 2169 if (ret != 0)
2167 goto err_ena; 2170 goto err_ena;
2168 2171
2172 dsp->booted = true;
2173
2169 /* Start the core running */ 2174 /* Start the core running */
2170 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, 2175 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
2171 ADSP1_CORE_ENA | ADSP1_START, 2176 ADSP1_CORE_ENA | ADSP1_START,
2172 ADSP1_CORE_ENA | ADSP1_START); 2177 ADSP1_CORE_ENA | ADSP1_START);
2178
2179 dsp->running = true;
2173 break; 2180 break;
2174 2181
2175 case SND_SOC_DAPM_PRE_PMD: 2182 case SND_SOC_DAPM_PRE_PMD:
2183 dsp->running = false;
2184 dsp->booted = false;
2185
2176 /* Halt the core */ 2186 /* Halt the core */
2177 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, 2187 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
2178 ADSP1_CORE_ENA | ADSP1_START, 0); 2188 ADSP1_CORE_ENA | ADSP1_START, 0);
@@ -2275,7 +2285,7 @@ static void wm_adsp2_boot_work(struct work_struct *work)
2275 if (ret != 0) 2285 if (ret != 0)
2276 goto err_ena; 2286 goto err_ena;
2277 2287
2278 dsp->running = true; 2288 dsp->booted = true;
2279 2289
2280 mutex_unlock(&dsp->pwr_lock); 2290 mutex_unlock(&dsp->pwr_lock);
2281 2291
@@ -2336,7 +2346,7 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
2336 case SND_SOC_DAPM_POST_PMU: 2346 case SND_SOC_DAPM_POST_PMU:
2337 flush_work(&dsp->boot_work); 2347 flush_work(&dsp->boot_work);
2338 2348
2339 if (!dsp->running) 2349 if (!dsp->booted)
2340 return -EIO; 2350 return -EIO;
2341 2351
2342 ret = regmap_update_bits(dsp->regmap, 2352 ret = regmap_update_bits(dsp->regmap,
@@ -2346,6 +2356,8 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
2346 if (ret != 0) 2356 if (ret != 0)
2347 goto err; 2357 goto err;
2348 2358
2359 dsp->running = true;
2360
2349 mutex_lock(&dsp->pwr_lock); 2361 mutex_lock(&dsp->pwr_lock);
2350 2362
2351 if (wm_adsp_fw[dsp->fw].num_caps != 0) 2363 if (wm_adsp_fw[dsp->fw].num_caps != 0)
@@ -2365,7 +2377,9 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
2365 2377
2366 dsp->fw_id = 0; 2378 dsp->fw_id = 0;
2367 dsp->fw_id_version = 0; 2379 dsp->fw_id_version = 0;
2380
2368 dsp->running = false; 2381 dsp->running = false;
2382 dsp->booted = false;
2369 2383
2370 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL, 2384 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
2371 ADSP2_CORE_ENA | ADSP2_START, 0); 2385 ADSP2_CORE_ENA | ADSP2_START, 0);
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
index be3b5bcb7f17..6a054e744068 100644
--- a/sound/soc/codecs/wm_adsp.h
+++ b/sound/soc/codecs/wm_adsp.h
@@ -61,6 +61,8 @@ struct wm_adsp {
61 61
62 int fw; 62 int fw;
63 int fw_ver; 63 int fw_ver;
64
65 bool booted;
64 bool running; 66 bool running;
65 67
66 struct list_head ctl_list; 68 struct list_head ctl_list;