blob: 6add70500ed81ac8f7ce2e1ebc891961bfd0d781 [file] [log] [blame]
Thomas Gleixner8e8e69d2019-05-29 07:17:59 -07001// SPDX-License-Identifier: GPL-2.0-only
Vinod Kould927fda2011-01-04 20:16:32 +05302/*
Mark Browna4b12992014-03-12 23:04:35 +00003 * sst_mfld_platform.c - Intel MID Platform driver
Vinod Kould927fda2011-01-04 20:16:32 +05304 *
Vinod Koul61b165c2014-06-13 18:03:56 +05305 * Copyright (C) 2010-2014 Intel Corp
Vinod Kould927fda2011-01-04 20:16:32 +05306 * Author: Vinod Koul <vinod.koul@intel.com>
7 * Author: Harsha Priya <priya.harsha@intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
Vinod Kould927fda2011-01-04 20:16:32 +053010 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vinod Kould927fda2011-01-04 20:16:32 +053011 */
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
14#include <linux/slab.h>
15#include <linux/io.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040016#include <linux/module.h>
Vinod Kould927fda2011-01-04 20:16:32 +053017#include <sound/core.h>
18#include <sound/pcm.h>
19#include <sound/pcm_params.h>
20#include <sound/soc.h>
Vinod Koulc514a912012-08-16 17:10:42 +053021#include <sound/compress_driver.h>
Vinod Koul61b165c2014-06-13 18:03:56 +053022#include <asm/platform_sst_audio.h>
Mark Browna4b12992014-03-12 23:04:35 +000023#include "sst-mfld-platform.h"
Vinod Koul61b165c2014-06-13 18:03:56 +053024#include "sst-atom-controls.h"
Vinod Kould927fda2011-01-04 20:16:32 +053025
Vinod Koul4b68b4e2014-05-05 14:27:50 +053026struct sst_device *sst;
Vinod Koul03c33042011-12-05 19:13:41 +053027static DEFINE_MUTEX(sst_lock);
28
29int sst_register_dsp(struct sst_device *dev)
30{
Takashi Iwai656a22a2013-11-05 18:40:01 +010031 if (WARN_ON(!dev))
32 return -EINVAL;
Vinod Koul03c33042011-12-05 19:13:41 +053033 if (!try_module_get(dev->dev->driver->owner))
34 return -ENODEV;
35 mutex_lock(&sst_lock);
36 if (sst) {
Subhransu S. Prusty02024752014-09-02 18:05:56 +053037 dev_err(dev->dev, "we already have a device %s\n", sst->name);
Vinod Koul03c33042011-12-05 19:13:41 +053038 module_put(dev->dev->driver->owner);
39 mutex_unlock(&sst_lock);
40 return -EEXIST;
41 }
Subhransu S. Prusty02024752014-09-02 18:05:56 +053042 dev_dbg(dev->dev, "registering device %s\n", dev->name);
Vinod Koul03c33042011-12-05 19:13:41 +053043 sst = dev;
44 mutex_unlock(&sst_lock);
45 return 0;
46}
47EXPORT_SYMBOL_GPL(sst_register_dsp);
48
49int sst_unregister_dsp(struct sst_device *dev)
50{
Takashi Iwai656a22a2013-11-05 18:40:01 +010051 if (WARN_ON(!dev))
52 return -EINVAL;
Vinod Koul03c33042011-12-05 19:13:41 +053053 if (dev != sst)
54 return -EINVAL;
55
56 mutex_lock(&sst_lock);
57
58 if (!sst) {
59 mutex_unlock(&sst_lock);
60 return -EIO;
61 }
62
63 module_put(sst->dev->driver->owner);
Subhransu S. Prusty02024752014-09-02 18:05:56 +053064 dev_dbg(dev->dev, "unreg %s\n", sst->name);
Vinod Koul03c33042011-12-05 19:13:41 +053065 sst = NULL;
66 mutex_unlock(&sst_lock);
67 return 0;
68}
69EXPORT_SYMBOL_GPL(sst_unregister_dsp);
70
Bhumika Goyala7468e42017-08-17 15:46:08 +053071static const struct snd_pcm_hardware sst_platform_pcm_hw = {
Vinod Kould927fda2011-01-04 20:16:32 +053072 .info = (SNDRV_PCM_INFO_INTERLEAVED |
73 SNDRV_PCM_INFO_DOUBLE |
74 SNDRV_PCM_INFO_PAUSE |
75 SNDRV_PCM_INFO_RESUME |
76 SNDRV_PCM_INFO_MMAP|
77 SNDRV_PCM_INFO_MMAP_VALID |
78 SNDRV_PCM_INFO_BLOCK_TRANSFER |
79 SNDRV_PCM_INFO_SYNC_START),
Vinod Kould927fda2011-01-04 20:16:32 +053080 .buffer_bytes_max = SST_MAX_BUFFER,
81 .period_bytes_min = SST_MIN_PERIOD_BYTES,
82 .period_bytes_max = SST_MAX_PERIOD_BYTES,
83 .periods_min = SST_MIN_PERIODS,
84 .periods_max = SST_MAX_PERIODS,
85 .fifo_size = SST_FIFO_SIZE,
86};
87
Vinod Koul61b165c2014-06-13 18:03:56 +053088static struct sst_dev_stream_map dpcm_strm_map[] = {
89 {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, /* Reserved, not in use */
90 {MERR_DPCM_AUDIO, 0, SNDRV_PCM_STREAM_PLAYBACK, PIPE_MEDIA1_IN, SST_TASK_ID_MEDIA, 0},
91 {MERR_DPCM_COMPR, 0, SNDRV_PCM_STREAM_PLAYBACK, PIPE_MEDIA0_IN, SST_TASK_ID_MEDIA, 0},
92 {MERR_DPCM_AUDIO, 0, SNDRV_PCM_STREAM_CAPTURE, PIPE_PCM1_OUT, SST_TASK_ID_MEDIA, 0},
Pierre-Louis Bossart8788f832015-12-17 20:35:44 -060093 {MERR_DPCM_DEEP_BUFFER, 0, SNDRV_PCM_STREAM_PLAYBACK, PIPE_MEDIA3_IN, SST_TASK_ID_MEDIA, 0},
Vinod Koul61b165c2014-06-13 18:03:56 +053094};
95
Vinod Koulc82351d2014-10-15 20:12:59 +053096static int sst_media_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
Vinod Kould927fda2011-01-04 20:16:32 +053097{
Vinod Koulc82351d2014-10-15 20:12:59 +053098
99 return sst_send_pipe_gains(dai, stream, mute);
100}
Harsha Priya5c685362011-01-11 14:50:35 +0530101
Vinod Kould927fda2011-01-04 20:16:32 +0530102/* helper functions */
Vinod Koul4496ffa2014-05-05 14:27:49 +0530103void sst_set_stream_status(struct sst_runtime_stream *stream,
Harsha Priya5c685362011-01-11 14:50:35 +0530104 int state)
105{
Lu Guanqund89b0a12011-04-08 15:38:48 +0800106 unsigned long flags;
107 spin_lock_irqsave(&stream->status_lock, flags);
Harsha Priya5c685362011-01-11 14:50:35 +0530108 stream->stream_status = state;
Lu Guanqund89b0a12011-04-08 15:38:48 +0800109 spin_unlock_irqrestore(&stream->status_lock, flags);
Harsha Priya5c685362011-01-11 14:50:35 +0530110}
111
112static inline int sst_get_stream_status(struct sst_runtime_stream *stream)
113{
114 int state;
Lu Guanqund89b0a12011-04-08 15:38:48 +0800115 unsigned long flags;
Harsha Priya5c685362011-01-11 14:50:35 +0530116
Lu Guanqund89b0a12011-04-08 15:38:48 +0800117 spin_lock_irqsave(&stream->status_lock, flags);
Harsha Priya5c685362011-01-11 14:50:35 +0530118 state = stream->stream_status;
Lu Guanqund89b0a12011-04-08 15:38:48 +0800119 spin_unlock_irqrestore(&stream->status_lock, flags);
Harsha Priya5c685362011-01-11 14:50:35 +0530120 return state;
121}
122
Vinod Koula870cdce2014-06-13 18:03:55 +0530123static void sst_fill_alloc_params(struct snd_pcm_substream *substream,
124 struct snd_sst_alloc_params_ext *alloc_param)
Harsha Priya5c685362011-01-11 14:50:35 +0530125{
Vinod Koula870cdce2014-06-13 18:03:55 +0530126 unsigned int channels;
127 snd_pcm_uframes_t period_size;
128 ssize_t periodbytes;
129 ssize_t buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
130 u32 buffer_addr = virt_to_phys(substream->dma_buffer.area);
Harsha Priya5c685362011-01-11 14:50:35 +0530131
Vinod Koula870cdce2014-06-13 18:03:55 +0530132 channels = substream->runtime->channels;
133 period_size = substream->runtime->period_size;
134 periodbytes = samples_to_bytes(substream->runtime, period_size);
135 alloc_param->ring_buf_info[0].addr = buffer_addr;
136 alloc_param->ring_buf_info[0].size = buffer_bytes;
137 alloc_param->sg_count = 1;
138 alloc_param->reserved = 0;
139 alloc_param->frag_size = periodbytes * channels;
140
141}
142static void sst_fill_pcm_params(struct snd_pcm_substream *substream,
143 struct snd_sst_stream_params *param)
144{
145 param->uc.pcm_params.num_chan = (u8) substream->runtime->channels;
146 param->uc.pcm_params.pcm_wd_sz = substream->runtime->sample_bits;
147 param->uc.pcm_params.sfreq = substream->runtime->rate;
148
149 /* PCM stream via ALSA interface */
150 param->uc.pcm_params.use_offload_path = 0;
151 param->uc.pcm_params.reserved2 = 0;
152 memset(param->uc.pcm_params.channel_map, 0, sizeof(u8));
153
154}
Vinod Koul61b165c2014-06-13 18:03:56 +0530155
156static int sst_get_stream_mapping(int dev, int sdev, int dir,
157 struct sst_dev_stream_map *map, int size)
Vinod Koula870cdce2014-06-13 18:03:55 +0530158{
Vinod Koul61b165c2014-06-13 18:03:56 +0530159 int i;
160
161 if (map == NULL)
162 return -EINVAL;
163
164
165 /* index 0 is not used in stream map */
166 for (i = 1; i < size; i++) {
167 if ((map[i].dev_num == dev) && (map[i].direction == dir))
168 return i;
169 }
170 return 0;
171}
172
173int sst_fill_stream_params(void *substream,
174 const struct sst_data *ctx, struct snd_sst_params *str_params, bool is_compress)
175{
176 int map_size;
177 int index;
178 struct sst_dev_stream_map *map;
Vinod Koula870cdce2014-06-13 18:03:55 +0530179 struct snd_pcm_substream *pstream = NULL;
180 struct snd_compr_stream *cstream = NULL;
181
Vinod Koul61b165c2014-06-13 18:03:56 +0530182 map = ctx->pdata->pdev_strm_map;
183 map_size = ctx->pdata->strm_map_size;
184
Pierre-Louis Bossart10583cd2018-12-16 16:49:08 -0600185 if (is_compress)
Vinod Koula870cdce2014-06-13 18:03:55 +0530186 cstream = (struct snd_compr_stream *)substream;
187 else
188 pstream = (struct snd_pcm_substream *)substream;
189
190 str_params->stream_type = SST_STREAM_TYPE_MUSIC;
191
192 /* For pcm streams */
Vinod Koul61b165c2014-06-13 18:03:56 +0530193 if (pstream) {
194 index = sst_get_stream_mapping(pstream->pcm->device,
195 pstream->number, pstream->stream,
196 map, map_size);
197 if (index <= 0)
198 return -EINVAL;
Vinod Koula870cdce2014-06-13 18:03:55 +0530199
Vinod Koul61b165c2014-06-13 18:03:56 +0530200 str_params->stream_id = index;
201 str_params->device_type = map[index].device_id;
202 str_params->task = map[index].task_id;
203
204 str_params->ops = (u8)pstream->stream;
205 }
206
207 if (cstream) {
208 index = sst_get_stream_mapping(cstream->device->device,
209 0, cstream->direction,
210 map, map_size);
211 if (index <= 0)
212 return -EINVAL;
213 str_params->stream_id = index;
214 str_params->device_type = map[index].device_id;
215 str_params->task = map[index].task_id;
216
217 str_params->ops = (u8)cstream->direction;
218 }
Vinod Koula870cdce2014-06-13 18:03:55 +0530219 return 0;
Harsha Priya5c685362011-01-11 14:50:35 +0530220}
221
Vinod Koula870cdce2014-06-13 18:03:55 +0530222static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
Subhransu S. Prusty6df5d762014-09-09 15:11:32 +0530223 struct snd_soc_dai *dai)
Vinod Kould927fda2011-01-04 20:16:32 +0530224{
225 struct sst_runtime_stream *stream =
226 substream->runtime->private_data;
Vinod Koula870cdce2014-06-13 18:03:55 +0530227 struct snd_sst_stream_params param = {{{0,},},};
228 struct snd_sst_params str_params = {0};
229 struct snd_sst_alloc_params_ext alloc_params = {0};
230 int ret_val = 0;
Subhransu S. Prusty6df5d762014-09-09 15:11:32 +0530231 struct sst_data *ctx = snd_soc_dai_get_drvdata(dai);
Vinod Kould927fda2011-01-04 20:16:32 +0530232
233 /* set codec params and inform SST driver the same */
Harsha Priya5c685362011-01-11 14:50:35 +0530234 sst_fill_pcm_params(substream, &param);
Vinod Koula870cdce2014-06-13 18:03:55 +0530235 sst_fill_alloc_params(substream, &alloc_params);
Vinod Kould927fda2011-01-04 20:16:32 +0530236 substream->runtime->dma_area = substream->dma_buffer.area;
Vinod Kould927fda2011-01-04 20:16:32 +0530237 str_params.sparams = param;
Vinod Koula870cdce2014-06-13 18:03:55 +0530238 str_params.aparams = alloc_params;
239 str_params.codec = SST_CODEC_TYPE_PCM;
240
241 /* fill the device type and stream id to pass to SST driver */
Vinod Koul61b165c2014-06-13 18:03:56 +0530242 ret_val = sst_fill_stream_params(substream, ctx, &str_params, false);
Vinod Kould927fda2011-01-04 20:16:32 +0530243 if (ret_val < 0)
244 return ret_val;
245
Vinod Koula870cdce2014-06-13 18:03:55 +0530246 stream->stream_info.str_id = str_params.stream_id;
247
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530248 ret_val = stream->ops->open(sst->dev, &str_params);
Vinod Koula870cdce2014-06-13 18:03:55 +0530249 if (ret_val <= 0)
250 return ret_val;
251
252
Vinod Kould927fda2011-01-04 20:16:32 +0530253 return ret_val;
254}
255
Vinod Koul9daa5bd2014-06-13 18:03:52 +0530256static void sst_period_elapsed(void *arg)
Vinod Kould927fda2011-01-04 20:16:32 +0530257{
Vinod Koul9daa5bd2014-06-13 18:03:52 +0530258 struct snd_pcm_substream *substream = arg;
Vinod Kould927fda2011-01-04 20:16:32 +0530259 struct sst_runtime_stream *stream;
Harsha Priya5c685362011-01-11 14:50:35 +0530260 int status;
Vinod Kould927fda2011-01-04 20:16:32 +0530261
262 if (!substream || !substream->runtime)
263 return;
264 stream = substream->runtime->private_data;
265 if (!stream)
266 return;
Harsha Priya5c685362011-01-11 14:50:35 +0530267 status = sst_get_stream_status(stream);
268 if (status != SST_PLATFORM_RUNNING)
Vinod Kould927fda2011-01-04 20:16:32 +0530269 return;
Vinod Kould927fda2011-01-04 20:16:32 +0530270 snd_pcm_period_elapsed(substream);
Vinod Kould927fda2011-01-04 20:16:32 +0530271}
272
273static int sst_platform_init_stream(struct snd_pcm_substream *substream)
274{
275 struct sst_runtime_stream *stream =
276 substream->runtime->private_data;
Kuninori Morimoto2ab9a402020-07-27 10:08:42 +0900277 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
Vinod Kould927fda2011-01-04 20:16:32 +0530278 int ret_val;
279
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530280 dev_dbg(rtd->dev, "setting buffer ptr param\n");
Harsha Priya5c685362011-01-11 14:50:35 +0530281 sst_set_stream_status(stream, SST_PLATFORM_INIT);
Vinod Kould927fda2011-01-04 20:16:32 +0530282 stream->stream_info.period_elapsed = sst_period_elapsed;
Vinod Koul9daa5bd2014-06-13 18:03:52 +0530283 stream->stream_info.arg = substream;
Vinod Kould927fda2011-01-04 20:16:32 +0530284 stream->stream_info.buffer_ptr = 0;
285 stream->stream_info.sfreq = substream->runtime->rate;
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530286 ret_val = stream->ops->stream_init(sst->dev, &stream->stream_info);
Vinod Kould927fda2011-01-04 20:16:32 +0530287 if (ret_val)
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530288 dev_err(rtd->dev, "control_set ret error %d\n", ret_val);
Vinod Kould927fda2011-01-04 20:16:32 +0530289 return ret_val;
290
291}
Vinod Kould927fda2011-01-04 20:16:32 +0530292
Vinod Koul01213272014-09-19 16:46:03 +0530293static int power_up_sst(struct sst_runtime_stream *stream)
294{
295 return stream->ops->power(sst->dev, true);
296}
297
298static void power_down_sst(struct sst_runtime_stream *stream)
299{
300 stream->ops->power(sst->dev, false);
301}
302
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530303static int sst_media_open(struct snd_pcm_substream *substream,
304 struct snd_soc_dai *dai)
Vinod Kould927fda2011-01-04 20:16:32 +0530305{
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530306 int ret_val = 0;
Lu Guanqun22be5042011-09-06 15:21:38 +0800307 struct snd_pcm_runtime *runtime = substream->runtime;
Vinod Kould927fda2011-01-04 20:16:32 +0530308 struct sst_runtime_stream *stream;
Lu Guanqun22be5042011-09-06 15:21:38 +0800309
Vinod Kould927fda2011-01-04 20:16:32 +0530310 stream = kzalloc(sizeof(*stream), GFP_KERNEL);
311 if (!stream)
312 return -ENOMEM;
Vinod Kould927fda2011-01-04 20:16:32 +0530313 spin_lock_init(&stream->status_lock);
Vinod Koul03c33042011-12-05 19:13:41 +0530314
315 /* get the sst ops */
316 mutex_lock(&sst_lock);
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530317 if (!sst ||
318 !try_module_get(sst->dev->driver->owner)) {
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530319 dev_err(dai->dev, "no device available to run\n");
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530320 ret_val = -ENODEV;
321 goto out_ops;
Vinod Koul03c33042011-12-05 19:13:41 +0530322 }
323 stream->ops = sst->ops;
324 mutex_unlock(&sst_lock);
325
Vinod Kould927fda2011-01-04 20:16:32 +0530326 stream->stream_info.str_id = 0;
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530327
Vinod Koul9daa5bd2014-06-13 18:03:52 +0530328 stream->stream_info.arg = substream;
Vinod Kould927fda2011-01-04 20:16:32 +0530329 /* allocate memory for SST API set */
Vinod Kould927fda2011-01-04 20:16:32 +0530330 runtime->private_data = stream;
Lu Guanqun283e42e2011-09-06 15:21:43 +0800331
Vinod Koul01213272014-09-19 16:46:03 +0530332 ret_val = power_up_sst(stream);
333 if (ret_val < 0)
Dinghao Liu062fa092020-08-13 16:41:10 +0800334 goto out_power_up;
Vinod Koul01213272014-09-19 16:46:03 +0530335
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530336 /* Make sure, that the period size is always even */
337 snd_pcm_hw_constraint_step(substream->runtime, 0,
338 SNDRV_PCM_HW_PARAM_PERIODS, 2);
339
340 return snd_pcm_hw_constraint_integer(runtime,
341 SNDRV_PCM_HW_PARAM_PERIODS);
342out_ops:
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530343 mutex_unlock(&sst_lock);
Dinghao Liu062fa092020-08-13 16:41:10 +0800344out_power_up:
345 kfree(stream);
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530346 return ret_val;
Vinod Kould927fda2011-01-04 20:16:32 +0530347}
348
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530349static void sst_media_close(struct snd_pcm_substream *substream,
350 struct snd_soc_dai *dai)
Vinod Kould927fda2011-01-04 20:16:32 +0530351{
352 struct sst_runtime_stream *stream;
Vinod Koul7d7c80f2016-12-08 23:01:35 +0530353 int str_id;
Vinod Kould927fda2011-01-04 20:16:32 +0530354
Vinod Kould927fda2011-01-04 20:16:32 +0530355 stream = substream->runtime->private_data;
Vinod Koul01213272014-09-19 16:46:03 +0530356 power_down_sst(stream);
357
Vinod Kould927fda2011-01-04 20:16:32 +0530358 str_id = stream->stream_info.str_id;
Vinod Kould927fda2011-01-04 20:16:32 +0530359 if (str_id)
Vinod Koul7d7c80f2016-12-08 23:01:35 +0530360 stream->ops->close(sst->dev, str_id);
Vinod Koul03c33042011-12-05 19:13:41 +0530361 module_put(sst->dev->driver->owner);
Vinod Kould927fda2011-01-04 20:16:32 +0530362 kfree(stream);
Vinod Koul61b165c2014-06-13 18:03:56 +0530363}
364
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530365static int sst_media_prepare(struct snd_pcm_substream *substream,
366 struct snd_soc_dai *dai)
Vinod Kould927fda2011-01-04 20:16:32 +0530367{
368 struct sst_runtime_stream *stream;
Pierre-Louis Bossartb0754c52020-08-13 15:01:29 -0500369 int ret_val, str_id;
Vinod Kould927fda2011-01-04 20:16:32 +0530370
Vinod Kould927fda2011-01-04 20:16:32 +0530371 stream = substream->runtime->private_data;
372 str_id = stream->stream_info.str_id;
373 if (stream->stream_info.str_id) {
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530374 ret_val = stream->ops->stream_drop(sst->dev, str_id);
Vinod Kould927fda2011-01-04 20:16:32 +0530375 return ret_val;
376 }
377
Subhransu S. Prusty6df5d762014-09-09 15:11:32 +0530378 ret_val = sst_platform_alloc_stream(substream, dai);
Vinod Koula870cdce2014-06-13 18:03:55 +0530379 if (ret_val <= 0)
Vinod Kould927fda2011-01-04 20:16:32 +0530380 return ret_val;
381 snprintf(substream->pcm->id, sizeof(substream->pcm->id),
382 "%d", stream->stream_info.str_id);
383
384 ret_val = sst_platform_init_stream(substream);
385 if (ret_val)
386 return ret_val;
387 substream->runtime->hw.info = SNDRV_PCM_INFO_BLOCK_TRANSFER;
Pierre-Louis Bossart5ab56a22020-08-13 15:01:33 -0500388 return 0;
Vinod Kould927fda2011-01-04 20:16:32 +0530389}
390
Vinod Koulc82351d2014-10-15 20:12:59 +0530391static int sst_enable_ssp(struct snd_pcm_substream *substream,
392 struct snd_soc_dai *dai)
393{
394 int ret = 0;
395
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900396 if (!snd_soc_dai_active(dai)) {
Vinod Koulc82351d2014-10-15 20:12:59 +0530397 ret = sst_handle_vb_timer(dai, true);
Vinod Koul711bc942015-05-06 22:06:42 +0530398 sst_fill_ssp_defaults(dai);
Vinod Koulc82351d2014-10-15 20:12:59 +0530399 }
400 return ret;
401}
402
Vinod Koul711bc942015-05-06 22:06:42 +0530403static int sst_be_hw_params(struct snd_pcm_substream *substream,
404 struct snd_pcm_hw_params *params,
405 struct snd_soc_dai *dai)
406{
407 int ret = 0;
408
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900409 if (snd_soc_dai_active(dai) == 1)
Vinod Koul711bc942015-05-06 22:06:42 +0530410 ret = send_ssp_cmd(dai, dai->name, 1);
411 return ret;
412}
413
Vinod Koul0b44e342015-05-06 22:06:43 +0530414static int sst_set_format(struct snd_soc_dai *dai, unsigned int fmt)
415{
416 int ret = 0;
417
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900418 if (!snd_soc_dai_active(dai))
Vinod Koul0b44e342015-05-06 22:06:43 +0530419 return 0;
420
421 ret = sst_fill_ssp_config(dai, fmt);
422 if (ret < 0)
423 dev_err(dai->dev, "sst_set_format failed..\n");
424
425 return ret;
426}
427
Vinod Koul83f125e2015-05-06 22:06:44 +0530428static int sst_platform_set_ssp_slot(struct snd_soc_dai *dai,
429 unsigned int tx_mask, unsigned int rx_mask,
430 int slots, int slot_width) {
431 int ret = 0;
432
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900433 if (!snd_soc_dai_active(dai))
Vinod Koul83f125e2015-05-06 22:06:44 +0530434 return ret;
435
436 ret = sst_fill_ssp_slot(dai, tx_mask, rx_mask, slots, slot_width);
437 if (ret < 0)
438 dev_err(dai->dev, "sst_fill_ssp_slot failed..%d\n", ret);
439
440 return ret;
441}
442
Vinod Koulc82351d2014-10-15 20:12:59 +0530443static void sst_disable_ssp(struct snd_pcm_substream *substream,
444 struct snd_soc_dai *dai)
445{
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900446 if (!snd_soc_dai_active(dai)) {
Vinod Koulc82351d2014-10-15 20:12:59 +0530447 send_ssp_cmd(dai, dai->name, 0);
448 sst_handle_vb_timer(dai, false);
449 }
450}
451
Gustavo A. R. Silvac115a312017-07-13 01:26:06 -0500452static const struct snd_soc_dai_ops sst_media_dai_ops = {
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530453 .startup = sst_media_open,
454 .shutdown = sst_media_close,
455 .prepare = sst_media_prepare,
Vinod Koulc82351d2014-10-15 20:12:59 +0530456 .mute_stream = sst_media_digital_mute,
457};
458
Gustavo A. R. Silvac115a312017-07-13 01:26:06 -0500459static const struct snd_soc_dai_ops sst_compr_dai_ops = {
Vinod Koulc82351d2014-10-15 20:12:59 +0530460 .mute_stream = sst_media_digital_mute,
461};
462
Gustavo A. R. Silvac115a312017-07-13 01:26:06 -0500463static const struct snd_soc_dai_ops sst_be_dai_ops = {
Vinod Koulc82351d2014-10-15 20:12:59 +0530464 .startup = sst_enable_ssp,
Vinod Koul711bc942015-05-06 22:06:42 +0530465 .hw_params = sst_be_hw_params,
Vinod Koul0b44e342015-05-06 22:06:43 +0530466 .set_fmt = sst_set_format,
Vinod Koul83f125e2015-05-06 22:06:44 +0530467 .set_tdm_slot = sst_platform_set_ssp_slot,
Vinod Koulc82351d2014-10-15 20:12:59 +0530468 .shutdown = sst_disable_ssp,
469};
470
471static struct snd_soc_dai_driver sst_platform_dai[] = {
472{
473 .name = "media-cpu-dai",
474 .ops = &sst_media_dai_ops,
475 .playback = {
476 .stream_name = "Headset Playback",
477 .channels_min = SST_STEREO,
478 .channels_max = SST_STEREO,
479 .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000,
Pierre-Louis Bossart098c2cd2015-12-17 20:35:46 -0600480 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
Vinod Koulc82351d2014-10-15 20:12:59 +0530481 },
482 .capture = {
483 .stream_name = "Headset Capture",
484 .channels_min = 1,
485 .channels_max = 2,
486 .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000,
Pierre-Louis Bossart098c2cd2015-12-17 20:35:46 -0600487 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
Vinod Koulc82351d2014-10-15 20:12:59 +0530488 },
489},
490{
Pierre-Louis Bossart8788f832015-12-17 20:35:44 -0600491 .name = "deepbuffer-cpu-dai",
492 .ops = &sst_media_dai_ops,
493 .playback = {
494 .stream_name = "Deepbuffer Playback",
495 .channels_min = SST_STEREO,
496 .channels_max = SST_STEREO,
497 .rates = SNDRV_PCM_RATE_44100|SNDRV_PCM_RATE_48000,
Pierre-Louis Bossart098c2cd2015-12-17 20:35:46 -0600498 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
Pierre-Louis Bossart8788f832015-12-17 20:35:44 -0600499 },
500},
501{
Vinod Koulc82351d2014-10-15 20:12:59 +0530502 .name = "compress-cpu-dai",
Jie Yang6f0c4222015-10-13 23:41:00 +0800503 .compress_new = snd_soc_new_compress,
Vinod Koulc82351d2014-10-15 20:12:59 +0530504 .ops = &sst_compr_dai_ops,
505 .playback = {
506 .stream_name = "Compress Playback",
Pierre-Louis Bossart292d4202016-02-02 12:49:49 -0600507 .channels_min = 1,
Vinod Koulc82351d2014-10-15 20:12:59 +0530508 },
509},
510/* BE CPU Dais */
511{
512 .name = "ssp0-port",
513 .ops = &sst_be_dai_ops,
514 .playback = {
515 .stream_name = "ssp0 Tx",
516 .channels_min = SST_STEREO,
517 .channels_max = SST_STEREO,
518 .rates = SNDRV_PCM_RATE_48000,
519 .formats = SNDRV_PCM_FMTBIT_S16_LE,
520 },
521 .capture = {
522 .stream_name = "ssp0 Rx",
523 .channels_min = SST_STEREO,
524 .channels_max = SST_STEREO,
525 .rates = SNDRV_PCM_RATE_48000,
526 .formats = SNDRV_PCM_FMTBIT_S16_LE,
527 },
528},
529{
530 .name = "ssp1-port",
531 .ops = &sst_be_dai_ops,
532 .playback = {
533 .stream_name = "ssp1 Tx",
534 .channels_min = SST_STEREO,
535 .channels_max = SST_STEREO,
536 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
537 .formats = SNDRV_PCM_FMTBIT_S16_LE,
538 },
539 .capture = {
540 .stream_name = "ssp1 Rx",
541 .channels_min = SST_STEREO,
542 .channels_max = SST_STEREO,
543 .rates = SNDRV_PCM_RATE_8000|SNDRV_PCM_RATE_16000|SNDRV_PCM_RATE_48000,
544 .formats = SNDRV_PCM_FMTBIT_S16_LE,
545 },
546},
547{
548 .name = "ssp2-port",
549 .ops = &sst_be_dai_ops,
550 .playback = {
551 .stream_name = "ssp2 Tx",
552 .channels_min = SST_STEREO,
553 .channels_max = SST_STEREO,
554 .rates = SNDRV_PCM_RATE_48000,
555 .formats = SNDRV_PCM_FMTBIT_S16_LE,
556 },
557 .capture = {
558 .stream_name = "ssp2 Rx",
559 .channels_min = SST_STEREO,
560 .channels_max = SST_STEREO,
561 .rates = SNDRV_PCM_RATE_48000,
562 .formats = SNDRV_PCM_FMTBIT_S16_LE,
563 },
564},
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530565};
566
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900567static int sst_soc_open(struct snd_soc_component *component,
568 struct snd_pcm_substream *substream)
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530569{
570 struct snd_pcm_runtime *runtime;
571
572 if (substream->pcm->internal)
573 return 0;
574
575 runtime = substream->runtime;
576 runtime->hw = sst_platform_pcm_hw;
577 return 0;
578}
579
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900580static int sst_soc_trigger(struct snd_soc_component *component,
581 struct snd_pcm_substream *substream, int cmd)
Vinod Kould927fda2011-01-04 20:16:32 +0530582{
583 int ret_val = 0, str_id;
584 struct sst_runtime_stream *stream;
Subhransu S. Prusty5981c2d2014-08-04 15:04:20 +0530585 int status;
Kuninori Morimoto2ab9a402020-07-27 10:08:42 +0900586 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
Vinod Kould927fda2011-01-04 20:16:32 +0530587
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900588 dev_dbg(rtd->dev, "%s called\n", __func__);
Vinod Kould2b16b82014-09-09 15:11:24 +0530589 if (substream->pcm->internal)
590 return 0;
Vinod Kould927fda2011-01-04 20:16:32 +0530591 stream = substream->runtime->private_data;
Vinod Kould927fda2011-01-04 20:16:32 +0530592 str_id = stream->stream_info.str_id;
Vinod Kould927fda2011-01-04 20:16:32 +0530593 switch (cmd) {
594 case SNDRV_PCM_TRIGGER_START:
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530595 dev_dbg(rtd->dev, "sst: Trigger Start\n");
Harsha Priyaa2117012011-01-11 14:50:59 +0530596 status = SST_PLATFORM_RUNNING;
Vinod Koul9daa5bd2014-06-13 18:03:52 +0530597 stream->stream_info.arg = substream;
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530598 ret_val = stream->ops->stream_start(sst->dev, str_id);
Vinod Kould927fda2011-01-04 20:16:32 +0530599 break;
600 case SNDRV_PCM_TRIGGER_STOP:
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530601 dev_dbg(rtd->dev, "sst: in stop\n");
Harsha Priyaa2117012011-01-11 14:50:59 +0530602 status = SST_PLATFORM_DROPPED;
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530603 ret_val = stream->ops->stream_drop(sst->dev, str_id);
Vinod Kould927fda2011-01-04 20:16:32 +0530604 break;
605 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
Vinod Koulfc9406a2015-02-12 09:59:57 +0530606 case SNDRV_PCM_TRIGGER_SUSPEND:
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530607 dev_dbg(rtd->dev, "sst: in pause\n");
Harsha Priyaa2117012011-01-11 14:50:59 +0530608 status = SST_PLATFORM_PAUSED;
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530609 ret_val = stream->ops->stream_pause(sst->dev, str_id);
Vinod Kould927fda2011-01-04 20:16:32 +0530610 break;
611 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
Vinod Koulfc9406a2015-02-12 09:59:57 +0530612 case SNDRV_PCM_TRIGGER_RESUME:
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530613 dev_dbg(rtd->dev, "sst: in pause release\n");
Harsha Priyaa2117012011-01-11 14:50:59 +0530614 status = SST_PLATFORM_RUNNING;
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530615 ret_val = stream->ops->stream_pause_release(sst->dev, str_id);
Vinod Kould927fda2011-01-04 20:16:32 +0530616 break;
617 default:
Harsha Priyaa2117012011-01-11 14:50:59 +0530618 return -EINVAL;
Vinod Kould927fda2011-01-04 20:16:32 +0530619 }
Subhransu S. Prusty5981c2d2014-08-04 15:04:20 +0530620
Harsha Priyaa2117012011-01-11 14:50:59 +0530621 if (!ret_val)
622 sst_set_stream_status(stream, status);
623
Vinod Kould927fda2011-01-04 20:16:32 +0530624 return ret_val;
625}
626
627
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900628static snd_pcm_uframes_t sst_soc_pointer(struct snd_soc_component *component,
629 struct snd_pcm_substream *substream)
Vinod Kould927fda2011-01-04 20:16:32 +0530630{
631 struct sst_runtime_stream *stream;
Harsha Priya5c685362011-01-11 14:50:35 +0530632 int ret_val, status;
Vinod Kould927fda2011-01-04 20:16:32 +0530633 struct pcm_stream_info *str_info;
Kuninori Morimoto2ab9a402020-07-27 10:08:42 +0900634 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
Vinod Kould927fda2011-01-04 20:16:32 +0530635
Vinod Kould927fda2011-01-04 20:16:32 +0530636 stream = substream->runtime->private_data;
Harsha Priya5c685362011-01-11 14:50:35 +0530637 status = sst_get_stream_status(stream);
638 if (status == SST_PLATFORM_INIT)
Vinod Kould927fda2011-01-04 20:16:32 +0530639 return 0;
Vinod Kould927fda2011-01-04 20:16:32 +0530640 str_info = &stream->stream_info;
Subhransu S. Prustyb12b087c2014-08-04 15:04:21 +0530641 ret_val = stream->ops->stream_read_tstamp(sst->dev, str_info);
Vinod Kould927fda2011-01-04 20:16:32 +0530642 if (ret_val) {
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530643 dev_err(rtd->dev, "sst: error code = %d\n", ret_val);
Vinod Kould927fda2011-01-04 20:16:32 +0530644 return ret_val;
645 }
Vinod Koul2a635822014-06-13 18:03:53 +0530646 substream->runtime->delay = str_info->pcm_delay;
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530647 return str_info->buffer_ptr;
xingchao9ab88432011-04-27 16:58:54 -0400648}
649
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900650static int sst_soc_pcm_new(struct snd_soc_component *component,
651 struct snd_soc_pcm_runtime *rtd)
Vinod Kould927fda2011-01-04 20:16:32 +0530652{
Kuninori Morimoto0d1571c2020-03-23 14:19:05 +0900653 struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
Liam Girdwood552d1ef2011-06-07 16:08:33 +0100654 struct snd_pcm *pcm = rtd->pcm;
Vinod Kould927fda2011-01-04 20:16:32 +0530655
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530656 if (dai->driver->playback.channels_min ||
657 dai->driver->capture.channels_min) {
Takashi Iwai022981452019-12-10 15:26:11 +0100658 snd_pcm_set_managed_buffer_all(pcm,
Vinod Kould927fda2011-01-04 20:16:32 +0530659 SNDRV_DMA_TYPE_CONTINUOUS,
Vinod Koul6cc0f4e2014-06-13 18:03:51 +0530660 snd_dma_continuous_data(GFP_DMA),
Vinod Kould927fda2011-01-04 20:16:32 +0530661 SST_MIN_BUFFER, SST_MAX_BUFFER);
Vinod Kould927fda2011-01-04 20:16:32 +0530662 }
Takashi Iwai62961dd2019-02-04 16:38:42 +0100663 return 0;
Vinod Kould927fda2011-01-04 20:16:32 +0530664}
Vinod Koulc514a912012-08-16 17:10:42 +0530665
Kuninori Morimoto68409622018-01-29 02:41:28 +0000666static int sst_soc_probe(struct snd_soc_component *component)
Vinod Kould8499c92014-08-04 15:15:55 +0530667{
Kuninori Morimoto68409622018-01-29 02:41:28 +0000668 struct sst_data *drv = dev_get_drvdata(component->dev);
Vinod Koul54e6bec2015-02-12 09:59:58 +0530669
Kuninori Morimoto68409622018-01-29 02:41:28 +0000670 drv->soc_card = component->card;
671 return sst_dsp_init_v2_dpcm(component);
Vinod Kould8499c92014-08-04 15:15:55 +0530672}
673
Guenter Roeck8f713702019-03-22 15:39:48 -0700674static void sst_soc_remove(struct snd_soc_component *component)
675{
676 struct sst_data *drv = dev_get_drvdata(component->dev);
677
678 drv->soc_card = NULL;
679}
680
Kuninori Morimoto68409622018-01-29 02:41:28 +0000681static const struct snd_soc_component_driver sst_soc_platform_drv = {
682 .name = DRV_NAME,
Vinod Kould8499c92014-08-04 15:15:55 +0530683 .probe = sst_soc_probe,
Guenter Roeck8f713702019-03-22 15:39:48 -0700684 .remove = sst_soc_remove,
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900685 .open = sst_soc_open,
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900686 .trigger = sst_soc_trigger,
687 .pointer = sst_soc_pointer,
Kuninori Morimotoc60e4452020-04-20 16:09:09 +0900688 .compress_ops = &sst_platform_compress_ops,
Kuninori Morimoto9b9974d2019-10-02 14:31:41 +0900689 .pcm_construct = sst_soc_pcm_new,
Vinod Kould927fda2011-01-04 20:16:32 +0530690};
691
692static int sst_platform_probe(struct platform_device *pdev)
693{
Vinod Koul61b165c2014-06-13 18:03:56 +0530694 struct sst_data *drv;
Vinod Kould927fda2011-01-04 20:16:32 +0530695 int ret;
Subhransu S. Prusty2741d432014-07-30 18:39:05 +0530696 struct sst_platform_data *pdata;
Vinod Kould927fda2011-01-04 20:16:32 +0530697
Vinod Koul61b165c2014-06-13 18:03:56 +0530698 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
Subhransu S. Prusty19a23a52014-07-30 18:36:00 +0530699 if (drv == NULL) {
Vinod Koul61b165c2014-06-13 18:03:56 +0530700 return -ENOMEM;
701 }
702
Subhransu S. Prusty2741d432014-07-30 18:39:05 +0530703 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
704 if (pdata == NULL) {
Subhransu S. Prusty2741d432014-07-30 18:39:05 +0530705 return -ENOMEM;
706 }
707
Vinod Koul61b165c2014-06-13 18:03:56 +0530708 pdata->pdev_strm_map = dpcm_strm_map;
709 pdata->strm_map_size = ARRAY_SIZE(dpcm_strm_map);
710 drv->pdata = pdata;
Subhransu S. Prusty3172fcd2014-10-30 16:21:44 +0530711 drv->pdev = pdev;
Vinod Koul61b165c2014-06-13 18:03:56 +0530712 mutex_init(&drv->lock);
713 dev_set_drvdata(&pdev->dev, drv);
714
Kuninori Morimoto68409622018-01-29 02:41:28 +0000715 ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv,
Vinod Kould927fda2011-01-04 20:16:32 +0530716 sst_platform_dai, ARRAY_SIZE(sst_platform_dai));
Kuninori Morimoto68409622018-01-29 02:41:28 +0000717 if (ret)
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530718 dev_err(&pdev->dev, "registering cpu dais failed\n");
Kuninori Morimoto68409622018-01-29 02:41:28 +0000719
Vinod Kould927fda2011-01-04 20:16:32 +0530720 return ret;
721}
722
723static int sst_platform_remove(struct platform_device *pdev)
724{
Subhransu S. Prusty02024752014-09-02 18:05:56 +0530725 dev_dbg(&pdev->dev, "sst_platform_remove success\n");
Vinod Kould927fda2011-01-04 20:16:32 +0530726 return 0;
727}
728
Vinod Koul54e6bec2015-02-12 09:59:58 +0530729#ifdef CONFIG_PM_SLEEP
730
731static int sst_soc_prepare(struct device *dev)
732{
733 struct sst_data *drv = dev_get_drvdata(dev);
Mengdong Lin1a497982015-11-18 02:34:11 -0500734 struct snd_soc_pcm_runtime *rtd;
Vinod Koul54e6bec2015-02-12 09:59:58 +0530735
Takashi Iwai2fc995a2016-11-25 16:54:06 +0100736 if (!drv->soc_card)
737 return 0;
738
Vinod Koul54e6bec2015-02-12 09:59:58 +0530739 /* suspend all pcms first */
740 snd_soc_suspend(drv->soc_card->dev);
741 snd_soc_poweroff(drv->soc_card->dev);
742
743 /* set the SSPs to idle */
Kuninori Morimotobcb1fd12018-09-18 01:29:35 +0000744 for_each_card_rtds(drv->soc_card, rtd) {
Kuninori Morimoto0d1571c2020-03-23 14:19:05 +0900745 struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
Vinod Koul54e6bec2015-02-12 09:59:58 +0530746
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900747 if (snd_soc_dai_active(dai)) {
Vinod Koul54e6bec2015-02-12 09:59:58 +0530748 send_ssp_cmd(dai, dai->name, 0);
749 sst_handle_vb_timer(dai, false);
750 }
751 }
752
753 return 0;
754}
755
756static void sst_soc_complete(struct device *dev)
757{
758 struct sst_data *drv = dev_get_drvdata(dev);
Mengdong Lin1a497982015-11-18 02:34:11 -0500759 struct snd_soc_pcm_runtime *rtd;
Vinod Koul54e6bec2015-02-12 09:59:58 +0530760
Takashi Iwai2fc995a2016-11-25 16:54:06 +0100761 if (!drv->soc_card)
762 return;
763
Vinod Koul54e6bec2015-02-12 09:59:58 +0530764 /* restart SSPs */
Kuninori Morimotobcb1fd12018-09-18 01:29:35 +0000765 for_each_card_rtds(drv->soc_card, rtd) {
Kuninori Morimoto0d1571c2020-03-23 14:19:05 +0900766 struct snd_soc_dai *dai = asoc_rtd_to_cpu(rtd, 0);
Vinod Koul54e6bec2015-02-12 09:59:58 +0530767
Kuninori Morimoto846d0a172020-05-15 09:47:22 +0900768 if (snd_soc_dai_active(dai)) {
Vinod Koul54e6bec2015-02-12 09:59:58 +0530769 sst_handle_vb_timer(dai, true);
770 send_ssp_cmd(dai, dai->name, 1);
771 }
772 }
773 snd_soc_resume(drv->soc_card->dev);
774}
775
776#else
777
778#define sst_soc_prepare NULL
779#define sst_soc_complete NULL
780
781#endif
782
783
784static const struct dev_pm_ops sst_platform_pm = {
785 .prepare = sst_soc_prepare,
786 .complete = sst_soc_complete,
787};
788
Vinod Kould927fda2011-01-04 20:16:32 +0530789static struct platform_driver sst_platform_driver = {
790 .driver = {
Mark Browna4b12992014-03-12 23:04:35 +0000791 .name = "sst-mfld-platform",
Vinod Koul54e6bec2015-02-12 09:59:58 +0530792 .pm = &sst_platform_pm,
Vinod Kould927fda2011-01-04 20:16:32 +0530793 },
794 .probe = sst_platform_probe,
795 .remove = sst_platform_remove,
796};
797
Axel Lin29515d62011-11-24 11:51:56 +0800798module_platform_driver(sst_platform_driver);
Vinod Kould927fda2011-01-04 20:16:32 +0530799
800MODULE_DESCRIPTION("ASoC Intel(R) MID Platform driver");
801MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>");
802MODULE_AUTHOR("Harsha Priya <priya.harsha@intel.com>");
803MODULE_LICENSE("GPL v2");
Andy Shevchenko231a0912017-01-16 15:12:29 +0200804MODULE_ALIAS("platform:sst-atom-hifi2-platform");
Mark Browna4b12992014-03-12 23:04:35 +0000805MODULE_ALIAS("platform:sst-mfld-platform");