aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/dwc/designware_i2s.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/dwc/designware_i2s.c')
-rw-r--r--sound/soc/dwc/designware_i2s.c86
1 files changed, 41 insertions, 45 deletions
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index 8d18bbda661b..06d3a34ac90a 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -335,13 +335,47 @@ static int dw_i2s_resume(struct snd_soc_dai *dai)
335#define dw_i2s_resume NULL 335#define dw_i2s_resume NULL
336#endif 336#endif
337 337
338static void dw_configure_dai_by_pd(struct dw_i2s_dev *dev,
339 struct snd_soc_dai_driver *dw_i2s_dai,
340 struct resource *res,
341 const struct i2s_platform_data *pdata)
342{
343 /* Set DMA slaves info */
344
345 dev->play_dma_data.data = pdata->play_dma_data;
346 dev->capture_dma_data.data = pdata->capture_dma_data;
347 dev->play_dma_data.addr = res->start + I2S_TXDMA;
348 dev->capture_dma_data.addr = res->start + I2S_RXDMA;
349 dev->play_dma_data.max_burst = 16;
350 dev->capture_dma_data.max_burst = 16;
351 dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
352 dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
353 dev->play_dma_data.filter = pdata->filter;
354 dev->capture_dma_data.filter = pdata->filter;
355
356 if (pdata->cap & DWC_I2S_PLAY) {
357 dev_dbg(dev->dev, " designware: play supported\n");
358 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
359 dw_i2s_dai->playback.channels_max = pdata->channel;
360 dw_i2s_dai->playback.formats = pdata->snd_fmts;
361 dw_i2s_dai->playback.rates = pdata->snd_rates;
362 }
363
364 if (pdata->cap & DWC_I2S_RECORD) {
365 dev_dbg(dev->dev, "designware: record supported\n");
366 dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
367 dw_i2s_dai->capture.channels_max = pdata->channel;
368 dw_i2s_dai->capture.formats = pdata->snd_fmts;
369 dw_i2s_dai->capture.rates = pdata->snd_rates;
370 }
371}
372
338static int dw_i2s_probe(struct platform_device *pdev) 373static int dw_i2s_probe(struct platform_device *pdev)
339{ 374{
340 const struct i2s_platform_data *pdata = pdev->dev.platform_data; 375 const struct i2s_platform_data *pdata = pdev->dev.platform_data;
341 struct dw_i2s_dev *dev; 376 struct dw_i2s_dev *dev;
342 struct resource *res; 377 struct resource *res;
343 int ret; 378 int ret;
344 unsigned int cap;
345 struct snd_soc_dai_driver *dw_i2s_dai; 379 struct snd_soc_dai_driver *dw_i2s_dai;
346 380
347 if (!pdata) { 381 if (!pdata) {
@@ -356,44 +390,23 @@ static int dw_i2s_probe(struct platform_device *pdev)
356 } 390 }
357 391
358 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL); 392 dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
359 if (!dw_i2s_dai) { 393 if (!dw_i2s_dai)
360 dev_err(&pdev->dev, "mem allocation failed for dai driver\n");
361 return -ENOMEM; 394 return -ENOMEM;
362 }
363 395
364 dw_i2s_dai->ops = &dw_i2s_dai_ops; 396 dw_i2s_dai->ops = &dw_i2s_dai_ops;
365 dw_i2s_dai->suspend = dw_i2s_suspend; 397 dw_i2s_dai->suspend = dw_i2s_suspend;
366 dw_i2s_dai->resume = dw_i2s_resume; 398 dw_i2s_dai->resume = dw_i2s_resume;
367 399
368 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 400 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
369 if (!res) {
370 dev_err(&pdev->dev, "no i2s resource defined\n");
371 return -ENODEV;
372 }
373
374 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res); 401 dev->i2s_base = devm_ioremap_resource(&pdev->dev, res);
375 if (IS_ERR(dev->i2s_base)) { 402 if (IS_ERR(dev->i2s_base))
376 dev_err(&pdev->dev, "ioremap fail for i2s_region\n");
377 return PTR_ERR(dev->i2s_base); 403 return PTR_ERR(dev->i2s_base);
378 }
379
380 cap = pdata->cap;
381 dev->capability = cap;
382 dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
383
384 /* Set DMA slaves info */
385 404
386 dev->play_dma_data.data = pdata->play_dma_data; 405 dev->dev = &pdev->dev;
387 dev->capture_dma_data.data = pdata->capture_dma_data; 406 dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata);
388 dev->play_dma_data.addr = res->start + I2S_TXDMA;
389 dev->capture_dma_data.addr = res->start + I2S_RXDMA;
390 dev->play_dma_data.max_burst = 16;
391 dev->capture_dma_data.max_burst = 16;
392 dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
393 dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
394 dev->play_dma_data.filter = pdata->filter;
395 dev->capture_dma_data.filter = pdata->filter;
396 407
408 dev->capability = pdata->cap;
409 dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
397 dev->clk = clk_get(&pdev->dev, NULL); 410 dev->clk = clk_get(&pdev->dev, NULL);
398 if (IS_ERR(dev->clk)) 411 if (IS_ERR(dev->clk))
399 return PTR_ERR(dev->clk); 412 return PTR_ERR(dev->clk);
@@ -402,23 +415,6 @@ static int dw_i2s_probe(struct platform_device *pdev)
402 if (ret < 0) 415 if (ret < 0)
403 goto err_clk_put; 416 goto err_clk_put;
404 417
405 if (cap & DWC_I2S_PLAY) {
406 dev_dbg(&pdev->dev, " designware: play supported\n");
407 dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
408 dw_i2s_dai->playback.channels_max = pdata->channel;
409 dw_i2s_dai->playback.formats = pdata->snd_fmts;
410 dw_i2s_dai->playback.rates = pdata->snd_rates;
411 }
412
413 if (cap & DWC_I2S_RECORD) {
414 dev_dbg(&pdev->dev, "designware: record supported\n");
415 dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
416 dw_i2s_dai->capture.channels_max = pdata->channel;
417 dw_i2s_dai->capture.formats = pdata->snd_fmts;
418 dw_i2s_dai->capture.rates = pdata->snd_rates;
419 }
420
421 dev->dev = &pdev->dev;
422 dev_set_drvdata(&pdev->dev, dev); 418 dev_set_drvdata(&pdev->dev, dev);
423 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, 419 ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component,
424 dw_i2s_dai, 1); 420 dw_i2s_dai, 1);