diff options
author | Andrew Jackson <Andrew.Jackson@arm.com> | 2014-12-19 11:18:07 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-12-22 08:59:53 -0500 |
commit | afa8603c6253204bf96c88739f711e89c2b00cd5 (patch) | |
tree | c84d22c4ae1be75a19b362e263f38a99fdfc0aeb /sound/soc/dwc | |
parent | be33465e58ab3a3300c5182844d45c67e73b15e0 (diff) |
ASoC: dwc: Reorder code in preparation for DT support
Move code that configures the DAI and DMA into a separate function. This
reduces the size of the dw_i2s_probe function and will make it easier to
add support for device tree to the driver.
Signed-off-by: Andrew Jackson <Andrew.Jackson@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/dwc')
-rw-r--r-- | sound/soc/dwc/designware_i2s.c | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c index f81e747c1c12..23a7c13b914f 100644 --- a/sound/soc/dwc/designware_i2s.c +++ b/sound/soc/dwc/designware_i2s.c | |||
@@ -324,13 +324,47 @@ static int dw_i2s_resume(struct snd_soc_dai *dai) | |||
324 | #define dw_i2s_resume NULL | 324 | #define dw_i2s_resume NULL |
325 | #endif | 325 | #endif |
326 | 326 | ||
327 | static void dw_configure_dai_by_pd(struct dw_i2s_dev *dev, | ||
328 | struct snd_soc_dai_driver *dw_i2s_dai, | ||
329 | struct resource *res, | ||
330 | const struct i2s_platform_data *pdata) | ||
331 | { | ||
332 | /* Set DMA slaves info */ | ||
333 | |||
334 | dev->play_dma_data.data = pdata->play_dma_data; | ||
335 | dev->capture_dma_data.data = pdata->capture_dma_data; | ||
336 | dev->play_dma_data.addr = res->start + I2S_TXDMA; | ||
337 | dev->capture_dma_data.addr = res->start + I2S_RXDMA; | ||
338 | dev->play_dma_data.max_burst = 16; | ||
339 | dev->capture_dma_data.max_burst = 16; | ||
340 | dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
341 | dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
342 | dev->play_dma_data.filter = pdata->filter; | ||
343 | dev->capture_dma_data.filter = pdata->filter; | ||
344 | |||
345 | if (pdata->cap & DWC_I2S_PLAY) { | ||
346 | dev_dbg(dev->dev, " designware: play supported\n"); | ||
347 | dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; | ||
348 | dw_i2s_dai->playback.channels_max = pdata->channel; | ||
349 | dw_i2s_dai->playback.formats = pdata->snd_fmts; | ||
350 | dw_i2s_dai->playback.rates = pdata->snd_rates; | ||
351 | } | ||
352 | |||
353 | if (pdata->cap & DWC_I2S_RECORD) { | ||
354 | dev_dbg(dev->dev, "designware: record supported\n"); | ||
355 | dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM; | ||
356 | dw_i2s_dai->capture.channels_max = pdata->channel; | ||
357 | dw_i2s_dai->capture.formats = pdata->snd_fmts; | ||
358 | dw_i2s_dai->capture.rates = pdata->snd_rates; | ||
359 | } | ||
360 | } | ||
361 | |||
327 | static int dw_i2s_probe(struct platform_device *pdev) | 362 | static int dw_i2s_probe(struct platform_device *pdev) |
328 | { | 363 | { |
329 | const struct i2s_platform_data *pdata = pdev->dev.platform_data; | 364 | const struct i2s_platform_data *pdata = pdev->dev.platform_data; |
330 | struct dw_i2s_dev *dev; | 365 | struct dw_i2s_dev *dev; |
331 | struct resource *res; | 366 | struct resource *res; |
332 | int ret; | 367 | int ret; |
333 | unsigned int cap; | ||
334 | struct snd_soc_dai_driver *dw_i2s_dai; | 368 | struct snd_soc_dai_driver *dw_i2s_dai; |
335 | 369 | ||
336 | if (!pdata) { | 370 | if (!pdata) { |
@@ -357,23 +391,11 @@ static int dw_i2s_probe(struct platform_device *pdev) | |||
357 | if (IS_ERR(dev->i2s_base)) | 391 | if (IS_ERR(dev->i2s_base)) |
358 | return PTR_ERR(dev->i2s_base); | 392 | return PTR_ERR(dev->i2s_base); |
359 | 393 | ||
360 | cap = pdata->cap; | 394 | dev->dev = &pdev->dev; |
361 | dev->capability = cap; | 395 | dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata); |
362 | dev->i2s_clk_cfg = pdata->i2s_clk_cfg; | ||
363 | |||
364 | /* Set DMA slaves info */ | ||
365 | |||
366 | dev->play_dma_data.data = pdata->play_dma_data; | ||
367 | dev->capture_dma_data.data = pdata->capture_dma_data; | ||
368 | dev->play_dma_data.addr = res->start + I2S_TXDMA; | ||
369 | dev->capture_dma_data.addr = res->start + I2S_RXDMA; | ||
370 | dev->play_dma_data.max_burst = 16; | ||
371 | dev->capture_dma_data.max_burst = 16; | ||
372 | dev->play_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
373 | dev->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
374 | dev->play_dma_data.filter = pdata->filter; | ||
375 | dev->capture_dma_data.filter = pdata->filter; | ||
376 | 396 | ||
397 | dev->capability = pdata->cap; | ||
398 | dev->i2s_clk_cfg = pdata->i2s_clk_cfg; | ||
377 | dev->clk = clk_get(&pdev->dev, NULL); | 399 | dev->clk = clk_get(&pdev->dev, NULL); |
378 | if (IS_ERR(dev->clk)) | 400 | if (IS_ERR(dev->clk)) |
379 | return PTR_ERR(dev->clk); | 401 | return PTR_ERR(dev->clk); |
@@ -382,23 +404,6 @@ static int dw_i2s_probe(struct platform_device *pdev) | |||
382 | if (ret < 0) | 404 | if (ret < 0) |
383 | goto err_clk_put; | 405 | goto err_clk_put; |
384 | 406 | ||
385 | if (cap & DWC_I2S_PLAY) { | ||
386 | dev_dbg(&pdev->dev, " designware: play supported\n"); | ||
387 | dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM; | ||
388 | dw_i2s_dai->playback.channels_max = pdata->channel; | ||
389 | dw_i2s_dai->playback.formats = pdata->snd_fmts; | ||
390 | dw_i2s_dai->playback.rates = pdata->snd_rates; | ||
391 | } | ||
392 | |||
393 | if (cap & DWC_I2S_RECORD) { | ||
394 | dev_dbg(&pdev->dev, "designware: record supported\n"); | ||
395 | dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM; | ||
396 | dw_i2s_dai->capture.channels_max = pdata->channel; | ||
397 | dw_i2s_dai->capture.formats = pdata->snd_fmts; | ||
398 | dw_i2s_dai->capture.rates = pdata->snd_rates; | ||
399 | } | ||
400 | |||
401 | dev->dev = &pdev->dev; | ||
402 | dev_set_drvdata(&pdev->dev, dev); | 407 | dev_set_drvdata(&pdev->dev, dev); |
403 | ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, | 408 | ret = snd_soc_register_component(&pdev->dev, &dw_i2s_component, |
404 | dw_i2s_dai, 1); | 409 | dw_i2s_dai, 1); |