blob: 498fb5346f1a81cfd63a0cdfdc1e4b9ab32ed3b7 [file] [log] [blame]
Mark Browna4b12992014-03-12 23:04:35 +00001/*
2 * Intel Baytrail SST PCM Support
3 * Copyright (c) 2014, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15#include <linux/module.h>
16#include <linux/dma-mapping.h>
17#include <linux/slab.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/pcm_params.h>
21#include <sound/soc.h>
22#include "sst-baytrail-ipc.h"
Jie Yang66a6fd92015-04-02 15:37:03 +080023#include "../common/sst-dsp-priv.h"
24#include "../common/sst-dsp.h"
Mark Browna4b12992014-03-12 23:04:35 +000025
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +000026#define DRV_NAME "byt-dai"
Mark Browna4b12992014-03-12 23:04:35 +000027#define BYT_PCM_COUNT 2
28
29static const struct snd_pcm_hardware sst_byt_pcm_hardware = {
30 .info = SNDRV_PCM_INFO_MMAP |
31 SNDRV_PCM_INFO_MMAP_VALID |
32 SNDRV_PCM_INFO_INTERLEAVED |
33 SNDRV_PCM_INFO_PAUSE |
34 SNDRV_PCM_INFO_RESUME,
35 .formats = SNDRV_PCM_FMTBIT_S16_LE |
Jie Yang8e897612014-07-14 17:37:36 +080036 SNDRV_PCM_FMTBIT_S24_LE,
Mark Browna4b12992014-03-12 23:04:35 +000037 .period_bytes_min = 384,
38 .period_bytes_max = 48000,
39 .periods_min = 2,
40 .periods_max = 250,
41 .buffer_bytes_max = 96000,
42};
43
44/* private data for each PCM DSP stream */
45struct sst_byt_pcm_data {
46 struct sst_byt_stream *stream;
47 struct snd_pcm_substream *substream;
48 struct mutex mutex;
Jarkko Nikulac83649e2014-05-08 16:07:21 +030049
50 /* latest DSP DMA hw pointer */
51 u32 hw_ptr;
Liam Girdwoodaf94aa52014-05-08 16:07:26 +030052
53 struct work_struct work;
Mark Browna4b12992014-03-12 23:04:35 +000054};
55
56/* private data for the driver */
57struct sst_byt_priv_data {
58 /* runtime DSP */
59 struct sst_byt *byt;
60
61 /* DAI data */
62 struct sst_byt_pcm_data pcm[BYT_PCM_COUNT];
Jarkko Nikulab80d19c2014-08-11 14:15:38 +030063
64 /* flag indicating is stream context restore needed after suspend */
65 bool restore_stream;
Mark Browna4b12992014-03-12 23:04:35 +000066};
67
68/* this may get called several times by oss emulation */
69static int sst_byt_pcm_hw_params(struct snd_pcm_substream *substream,
70 struct snd_pcm_hw_params *params)
71{
72 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +000073 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
74 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Liam Girdwood3a46c7b2014-05-14 17:20:53 +030075 struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
Mark Browna4b12992014-03-12 23:04:35 +000076 struct sst_byt *byt = pdata->byt;
77 u32 rate, bits;
78 u8 channels;
79 int ret, playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
80
81 dev_dbg(rtd->dev, "PCM: hw_params, pcm_data %p\n", pcm_data);
82
83 ret = sst_byt_stream_type(byt, pcm_data->stream,
84 1, 1, !playback);
85 if (ret < 0) {
86 dev_err(rtd->dev, "failed to set stream format %d\n", ret);
87 return ret;
88 }
89
90 rate = params_rate(params);
91 ret = sst_byt_stream_set_rate(byt, pcm_data->stream, rate);
92 if (ret < 0) {
93 dev_err(rtd->dev, "could not set rate %d\n", rate);
94 return ret;
95 }
96
97 bits = snd_pcm_format_width(params_format(params));
98 ret = sst_byt_stream_set_bits(byt, pcm_data->stream, bits);
99 if (ret < 0) {
100 dev_err(rtd->dev, "could not set formats %d\n",
101 params_rate(params));
102 return ret;
103 }
104
105 channels = (u8)(params_channels(params) & 0xF);
106 ret = sst_byt_stream_set_channels(byt, pcm_data->stream, channels);
107 if (ret < 0) {
108 dev_err(rtd->dev, "could not set channels %d\n",
109 params_rate(params));
110 return ret;
111 }
112
113 snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
114
115 ret = sst_byt_stream_buffer(byt, pcm_data->stream,
116 substream->dma_buffer.addr,
117 params_buffer_bytes(params));
118 if (ret < 0) {
119 dev_err(rtd->dev, "PCM: failed to set DMA buffer %d\n", ret);
120 return ret;
121 }
122
123 ret = sst_byt_stream_commit(byt, pcm_data->stream);
124 if (ret < 0) {
125 dev_err(rtd->dev, "PCM: failed stream commit %d\n", ret);
126 return ret;
127 }
128
129 return 0;
130}
131
132static int sst_byt_pcm_hw_free(struct snd_pcm_substream *substream)
133{
134 struct snd_soc_pcm_runtime *rtd = substream->private_data;
135
136 dev_dbg(rtd->dev, "PCM: hw_free\n");
137 snd_pcm_lib_free_pages(substream);
138
139 return 0;
140}
141
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300142static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream)
143{
144 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000145 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
146 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Liam Girdwood3a46c7b2014-05-14 17:20:53 +0300147 struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300148 struct sst_byt *byt = pdata->byt;
149 int ret;
150
151 /* commit stream using existing stream params */
152 ret = sst_byt_stream_commit(byt, pcm_data->stream);
153 if (ret < 0) {
154 dev_err(rtd->dev, "PCM: failed stream commit %d\n", ret);
155 return ret;
156 }
157
158 sst_byt_stream_start(byt, pcm_data->stream, pcm_data->hw_ptr);
159
160 dev_dbg(rtd->dev, "stream context restored at offset %d\n",
161 pcm_data->hw_ptr);
162
163 return 0;
164}
165
166static void sst_byt_pcm_work(struct work_struct *work)
167{
168 struct sst_byt_pcm_data *pcm_data =
169 container_of(work, struct sst_byt_pcm_data, work);
170
Kevin Strasser2fa190c2014-05-19 11:14:23 +0300171 if (snd_pcm_running(pcm_data->substream))
172 sst_byt_pcm_restore_stream_context(pcm_data->substream);
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300173}
174
Mark Browna4b12992014-03-12 23:04:35 +0000175static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
176{
177 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000178 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
179 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Liam Girdwood3a46c7b2014-05-14 17:20:53 +0300180 struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
Mark Browna4b12992014-03-12 23:04:35 +0000181 struct sst_byt *byt = pdata->byt;
182
183 dev_dbg(rtd->dev, "PCM: trigger %d\n", cmd);
184
185 switch (cmd) {
186 case SNDRV_PCM_TRIGGER_START:
Jarkko Nikula58dcc482014-05-26 16:56:30 +0300187 pcm_data->hw_ptr = 0;
Jarkko Nikulaa6686ed2014-05-08 16:07:23 +0300188 sst_byt_stream_start(byt, pcm_data->stream, 0);
Mark Browna4b12992014-03-12 23:04:35 +0000189 break;
190 case SNDRV_PCM_TRIGGER_RESUME:
Pierre-Louis Bossarte2954502018-12-16 16:49:07 -0600191 if (pdata->restore_stream)
Jarkko Nikulab80d19c2014-08-11 14:15:38 +0300192 schedule_work(&pcm_data->work);
193 else
194 sst_byt_stream_resume(byt, pcm_data->stream);
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300195 break;
Mark Browna4b12992014-03-12 23:04:35 +0000196 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
197 sst_byt_stream_resume(byt, pcm_data->stream);
198 break;
199 case SNDRV_PCM_TRIGGER_STOP:
200 sst_byt_stream_stop(byt, pcm_data->stream);
201 break;
202 case SNDRV_PCM_TRIGGER_SUSPEND:
Jarkko Nikulab80d19c2014-08-11 14:15:38 +0300203 pdata->restore_stream = false;
Mark Browna4b12992014-03-12 23:04:35 +0000204 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
205 sst_byt_stream_pause(byt, pcm_data->stream);
206 break;
207 default:
208 break;
209 }
210
211 return 0;
212}
213
214static u32 byt_notify_pointer(struct sst_byt_stream *stream, void *data)
215{
216 struct sst_byt_pcm_data *pcm_data = data;
217 struct snd_pcm_substream *substream = pcm_data->substream;
218 struct snd_pcm_runtime *runtime = substream->runtime;
219 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000220 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
221 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Jarkko Nikulac83649e2014-05-08 16:07:21 +0300222 struct sst_byt *byt = pdata->byt;
223 u32 pos, hw_pos;
Mark Browna4b12992014-03-12 23:04:35 +0000224
Jarkko Nikulac83649e2014-05-08 16:07:21 +0300225 hw_pos = sst_byt_get_dsp_position(byt, pcm_data->stream,
226 snd_pcm_lib_buffer_bytes(substream));
227 pcm_data->hw_ptr = hw_pos;
Mark Browna4b12992014-03-12 23:04:35 +0000228 pos = frames_to_bytes(runtime,
229 (runtime->control->appl_ptr %
230 runtime->buffer_size));
231
Jarkko Nikulac83649e2014-05-08 16:07:21 +0300232 dev_dbg(rtd->dev, "PCM: App/DMA pointer %u/%u bytes\n", pos, hw_pos);
Mark Browna4b12992014-03-12 23:04:35 +0000233
234 snd_pcm_period_elapsed(substream);
235 return pos;
236}
237
238static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream)
239{
240 struct snd_soc_pcm_runtime *rtd = substream->private_data;
241 struct snd_pcm_runtime *runtime = substream->runtime;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000242 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
243 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Liam Girdwood3a46c7b2014-05-14 17:20:53 +0300244 struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
Mark Browna4b12992014-03-12 23:04:35 +0000245
Jarkko Nikulac83649e2014-05-08 16:07:21 +0300246 dev_dbg(rtd->dev, "PCM: DMA pointer %u bytes\n", pcm_data->hw_ptr);
Mark Browna4b12992014-03-12 23:04:35 +0000247
Jarkko Nikulac83649e2014-05-08 16:07:21 +0300248 return bytes_to_frames(runtime, pcm_data->hw_ptr);
Mark Browna4b12992014-03-12 23:04:35 +0000249}
250
251static int sst_byt_pcm_open(struct snd_pcm_substream *substream)
252{
253 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000254 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
255 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Liam Girdwood3a46c7b2014-05-14 17:20:53 +0300256 struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
Mark Browna4b12992014-03-12 23:04:35 +0000257 struct sst_byt *byt = pdata->byt;
258
259 dev_dbg(rtd->dev, "PCM: open\n");
260
Mark Browna4b12992014-03-12 23:04:35 +0000261 mutex_lock(&pcm_data->mutex);
262
Mark Browna4b12992014-03-12 23:04:35 +0000263 pcm_data->substream = substream;
264
265 snd_soc_set_runtime_hwparams(substream, &sst_byt_pcm_hardware);
266
Jarkko Nikula8c44b2b2014-05-15 14:41:48 +0300267 pcm_data->stream = sst_byt_stream_new(byt, substream->stream + 1,
Mark Browna4b12992014-03-12 23:04:35 +0000268 byt_notify_pointer, pcm_data);
269 if (pcm_data->stream == NULL) {
270 dev_err(rtd->dev, "failed to create stream\n");
271 mutex_unlock(&pcm_data->mutex);
272 return -EINVAL;
273 }
274
275 mutex_unlock(&pcm_data->mutex);
276 return 0;
277}
278
279static int sst_byt_pcm_close(struct snd_pcm_substream *substream)
280{
281 struct snd_soc_pcm_runtime *rtd = substream->private_data;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000282 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
283 struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
Liam Girdwood3a46c7b2014-05-14 17:20:53 +0300284 struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
Mark Browna4b12992014-03-12 23:04:35 +0000285 struct sst_byt *byt = pdata->byt;
286 int ret;
287
288 dev_dbg(rtd->dev, "PCM: close\n");
289
Kevin Strasser2fa190c2014-05-19 11:14:23 +0300290 cancel_work_sync(&pcm_data->work);
Mark Browna4b12992014-03-12 23:04:35 +0000291 mutex_lock(&pcm_data->mutex);
292 ret = sst_byt_stream_free(byt, pcm_data->stream);
293 if (ret < 0) {
294 dev_dbg(rtd->dev, "Free stream fail\n");
295 goto out;
296 }
297 pcm_data->stream = NULL;
298
299out:
300 mutex_unlock(&pcm_data->mutex);
301 return ret;
302}
303
304static int sst_byt_pcm_mmap(struct snd_pcm_substream *substream,
305 struct vm_area_struct *vma)
306{
307 struct snd_soc_pcm_runtime *rtd = substream->private_data;
308
309 dev_dbg(rtd->dev, "PCM: mmap\n");
310 return snd_pcm_lib_default_mmap(substream, vma);
311}
312
Arvind Yadavf2c402b2017-08-14 11:26:27 +0530313static const struct snd_pcm_ops sst_byt_pcm_ops = {
Mark Browna4b12992014-03-12 23:04:35 +0000314 .open = sst_byt_pcm_open,
315 .close = sst_byt_pcm_close,
316 .ioctl = snd_pcm_lib_ioctl,
317 .hw_params = sst_byt_pcm_hw_params,
318 .hw_free = sst_byt_pcm_hw_free,
319 .trigger = sst_byt_pcm_trigger,
320 .pointer = sst_byt_pcm_pointer,
321 .mmap = sst_byt_pcm_mmap,
322};
323
Mark Browna4b12992014-03-12 23:04:35 +0000324static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd)
325{
326 struct snd_pcm *pcm = rtd->pcm;
327 size_t size;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000328 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
329 struct sst_pdata *pdata = dev_get_platdata(component->dev);
Mark Browna4b12992014-03-12 23:04:35 +0000330 int ret = 0;
331
Mark Browna4b12992014-03-12 23:04:35 +0000332 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
333 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
334 size = sst_byt_pcm_hardware.buffer_bytes_max;
335 ret = snd_pcm_lib_preallocate_pages_for_all(pcm,
336 SNDRV_DMA_TYPE_DEV,
Jarkko Nikuladfe19512014-05-09 16:47:44 +0300337 pdata->dma_dev,
Mark Browna4b12992014-03-12 23:04:35 +0000338 size, size);
339 if (ret) {
340 dev_err(rtd->dev, "dma buffer allocation failed %d\n",
341 ret);
342 return ret;
343 }
344 }
345
346 return ret;
347}
348
349static struct snd_soc_dai_driver byt_dais[] = {
350 {
Liam Girdwood49fee172014-05-14 17:20:54 +0300351 .name = "Baytrail PCM",
Mark Browna4b12992014-03-12 23:04:35 +0000352 .playback = {
353 .stream_name = "System Playback",
354 .channels_min = 2,
355 .channels_max = 2,
356 .rates = SNDRV_PCM_RATE_48000,
357 .formats = SNDRV_PCM_FMTBIT_S24_3LE |
358 SNDRV_PCM_FMTBIT_S16_LE,
359 },
Mark Browna4b12992014-03-12 23:04:35 +0000360 .capture = {
361 .stream_name = "Analog Capture",
362 .channels_min = 2,
363 .channels_max = 2,
364 .rates = SNDRV_PCM_RATE_48000,
365 .formats = SNDRV_PCM_FMTBIT_S16_LE,
366 },
367 },
368};
369
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000370static int sst_byt_pcm_probe(struct snd_soc_component *component)
Mark Browna4b12992014-03-12 23:04:35 +0000371{
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000372 struct sst_pdata *plat_data = dev_get_platdata(component->dev);
Mark Browna4b12992014-03-12 23:04:35 +0000373 struct sst_byt_priv_data *priv_data;
374 int i;
375
376 if (!plat_data)
377 return -ENODEV;
378
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000379 priv_data = devm_kzalloc(component->dev, sizeof(*priv_data),
Mark Browna4b12992014-03-12 23:04:35 +0000380 GFP_KERNEL);
Julia Lawall3f317c92015-12-20 12:15:53 +0100381 if (!priv_data)
382 return -ENOMEM;
Mark Browna4b12992014-03-12 23:04:35 +0000383 priv_data->byt = plat_data->dsp;
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000384 snd_soc_component_set_drvdata(component, priv_data);
Mark Browna4b12992014-03-12 23:04:35 +0000385
Liam Girdwood49fee172014-05-14 17:20:54 +0300386 for (i = 0; i < BYT_PCM_COUNT; i++) {
Mark Browna4b12992014-03-12 23:04:35 +0000387 mutex_init(&priv_data->pcm[i].mutex);
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300388 INIT_WORK(&priv_data->pcm[i].work, sst_byt_pcm_work);
389 }
Mark Browna4b12992014-03-12 23:04:35 +0000390
391 return 0;
392}
393
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000394static const struct snd_soc_component_driver byt_dai_component = {
395 .name = DRV_NAME,
Mark Browna4b12992014-03-12 23:04:35 +0000396 .probe = sst_byt_pcm_probe,
Mark Browna4b12992014-03-12 23:04:35 +0000397 .ops = &sst_byt_pcm_ops,
398 .pcm_new = sst_byt_pcm_new,
Mark Browna4b12992014-03-12 23:04:35 +0000399};
400
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300401#ifdef CONFIG_PM
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300402static int sst_byt_pcm_dev_suspend_late(struct device *dev)
403{
404 struct sst_pdata *sst_pdata = dev_get_platdata(dev);
Jarkko Nikulab80d19c2014-08-11 14:15:38 +0300405 struct sst_byt_priv_data *priv_data = dev_get_drvdata(dev);
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300406 int ret;
407
408 dev_dbg(dev, "suspending late\n");
409
410 ret = sst_byt_dsp_suspend_late(dev, sst_pdata);
411 if (ret < 0) {
412 dev_err(dev, "failed to suspend %d\n", ret);
413 return ret;
414 }
415
Jarkko Nikulab80d19c2014-08-11 14:15:38 +0300416 priv_data->restore_stream = true;
417
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300418 return ret;
419}
420
421static int sst_byt_pcm_dev_resume_early(struct device *dev)
422{
423 struct sst_pdata *sst_pdata = dev_get_platdata(dev);
Jarkko Nikula92465392014-08-11 14:15:37 +0300424 int ret;
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300425
426 dev_dbg(dev, "resume early\n");
427
428 /* load fw and boot DSP */
Jarkko Nikula92465392014-08-11 14:15:37 +0300429 ret = sst_byt_dsp_boot(dev, sst_pdata);
430 if (ret)
431 return ret;
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300432
433 /* wait for FW to finish booting */
434 return sst_byt_dsp_wait_for_ready(dev, sst_pdata);
435}
436
437static const struct dev_pm_ops sst_byt_pm_ops = {
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300438 .suspend_late = sst_byt_pcm_dev_suspend_late,
439 .resume_early = sst_byt_pcm_dev_resume_early,
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300440};
441
442#define SST_BYT_PM_OPS (&sst_byt_pm_ops)
443#else
444#define SST_BYT_PM_OPS NULL
445#endif
446
Mark Browna4b12992014-03-12 23:04:35 +0000447static int sst_byt_pcm_dev_probe(struct platform_device *pdev)
448{
449 struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev);
450 int ret;
451
452 ret = sst_byt_dsp_init(&pdev->dev, sst_pdata);
453 if (ret < 0)
454 return -ENODEV;
455
Kuninori Morimoto81dc5f32018-01-29 02:42:02 +0000456 ret = devm_snd_soc_register_component(&pdev->dev, &byt_dai_component,
457 byt_dais, ARRAY_SIZE(byt_dais));
Mark Browna4b12992014-03-12 23:04:35 +0000458 if (ret < 0)
459 goto err_plat;
460
Mark Browna4b12992014-03-12 23:04:35 +0000461 return 0;
462
Mark Browna4b12992014-03-12 23:04:35 +0000463err_plat:
464 sst_byt_dsp_free(&pdev->dev, sst_pdata);
465 return ret;
466}
467
468static int sst_byt_pcm_dev_remove(struct platform_device *pdev)
469{
470 struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev);
471
Mark Browna4b12992014-03-12 23:04:35 +0000472 sst_byt_dsp_free(&pdev->dev, sst_pdata);
473
474 return 0;
475}
476
477static struct platform_driver sst_byt_pcm_driver = {
478 .driver = {
479 .name = "baytrail-pcm-audio",
Liam Girdwoodaf94aa52014-05-08 16:07:26 +0300480 .pm = SST_BYT_PM_OPS,
Mark Browna4b12992014-03-12 23:04:35 +0000481 },
482
483 .probe = sst_byt_pcm_dev_probe,
484 .remove = sst_byt_pcm_dev_remove,
485};
486module_platform_driver(sst_byt_pcm_driver);
487
488MODULE_AUTHOR("Jarkko Nikula");
489MODULE_DESCRIPTION("Baytrail PCM");
490MODULE_LICENSE("GPL v2");
491MODULE_ALIAS("platform:baytrail-pcm-audio");