aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/tegra/tegra20_spdif.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/tegra/tegra20_spdif.c')
-rw-r--r--sound/soc/tegra/tegra20_spdif.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c
index 9141477a528d..a0c3640572b9 100644
--- a/sound/soc/tegra/tegra20_spdif.c
+++ b/sound/soc/tegra/tegra20_spdif.c
@@ -265,7 +265,7 @@ static const struct regmap_config tegra20_spdif_regmap_config = {
265static int tegra20_spdif_platform_probe(struct platform_device *pdev) 265static int tegra20_spdif_platform_probe(struct platform_device *pdev)
266{ 266{
267 struct tegra20_spdif *spdif; 267 struct tegra20_spdif *spdif;
268 struct resource *mem, *memregion, *dmareq; 268 struct resource *mem, *dmareq;
269 void __iomem *regs; 269 void __iomem *regs;
270 int ret; 270 int ret;
271 271
@@ -273,45 +273,26 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
273 GFP_KERNEL); 273 GFP_KERNEL);
274 if (!spdif) { 274 if (!spdif) {
275 dev_err(&pdev->dev, "Can't allocate tegra20_spdif\n"); 275 dev_err(&pdev->dev, "Can't allocate tegra20_spdif\n");
276 ret = -ENOMEM; 276 return -ENOMEM;
277 goto err;
278 } 277 }
279 dev_set_drvdata(&pdev->dev, spdif); 278 dev_set_drvdata(&pdev->dev, spdif);
280 279
281 spdif->clk_spdif_out = clk_get(&pdev->dev, "spdif_out"); 280 spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out");
282 if (IS_ERR(spdif->clk_spdif_out)) { 281 if (IS_ERR(spdif->clk_spdif_out)) {
283 pr_err("Can't retrieve spdif clock\n"); 282 pr_err("Can't retrieve spdif clock\n");
284 ret = PTR_ERR(spdif->clk_spdif_out); 283 ret = PTR_ERR(spdif->clk_spdif_out);
285 goto err; 284 return ret;
286 } 285 }
287 286
288 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 287 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
289 if (!mem) { 288 regs = devm_ioremap_resource(&pdev->dev, mem);
290 dev_err(&pdev->dev, "No memory resource\n"); 289 if (IS_ERR(regs))
291 ret = -ENODEV; 290 return PTR_ERR(regs);
292 goto err_clk_put;
293 }
294 291
295 dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0); 292 dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0);
296 if (!dmareq) { 293 if (!dmareq) {
297 dev_err(&pdev->dev, "No DMA resource\n"); 294 dev_err(&pdev->dev, "No DMA resource\n");
298 ret = -ENODEV; 295 return -ENODEV;
299 goto err_clk_put;
300 }
301
302 memregion = devm_request_mem_region(&pdev->dev, mem->start,
303 resource_size(mem), DRV_NAME);
304 if (!memregion) {
305 dev_err(&pdev->dev, "Memory region already claimed\n");
306 ret = -EBUSY;
307 goto err_clk_put;
308 }
309
310 regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
311 if (!regs) {
312 dev_err(&pdev->dev, "ioremap failed\n");
313 ret = -ENOMEM;
314 goto err_clk_put;
315 } 296 }
316 297
317 spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs, 298 spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
@@ -319,7 +300,7 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
319 if (IS_ERR(spdif->regmap)) { 300 if (IS_ERR(spdif->regmap)) {
320 dev_err(&pdev->dev, "regmap init failed\n"); 301 dev_err(&pdev->dev, "regmap init failed\n");
321 ret = PTR_ERR(spdif->regmap); 302 ret = PTR_ERR(spdif->regmap);
322 goto err_clk_put; 303 return ret;
323 } 304 }
324 305
325 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; 306 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT;
@@ -335,7 +316,7 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
335 } 316 }
336 317
337 ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component, 318 ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component,
338 &tegra20_spdif_dai, 1); 319 &tegra20_spdif_dai, 1);
339 if (ret) { 320 if (ret) {
340 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); 321 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
341 ret = -ENOMEM; 322 ret = -ENOMEM;
@@ -357,16 +338,12 @@ err_suspend:
357 tegra20_spdif_runtime_suspend(&pdev->dev); 338 tegra20_spdif_runtime_suspend(&pdev->dev);
358err_pm_disable: 339err_pm_disable:
359 pm_runtime_disable(&pdev->dev); 340 pm_runtime_disable(&pdev->dev);
360err_clk_put: 341
361 clk_put(spdif->clk_spdif_out);
362err:
363 return ret; 342 return ret;
364} 343}
365 344
366static int tegra20_spdif_platform_remove(struct platform_device *pdev) 345static int tegra20_spdif_platform_remove(struct platform_device *pdev)
367{ 346{
368 struct tegra20_spdif *spdif = dev_get_drvdata(&pdev->dev);
369
370 pm_runtime_disable(&pdev->dev); 347 pm_runtime_disable(&pdev->dev);
371 if (!pm_runtime_status_suspended(&pdev->dev)) 348 if (!pm_runtime_status_suspended(&pdev->dev))
372 tegra20_spdif_runtime_suspend(&pdev->dev); 349 tegra20_spdif_runtime_suspend(&pdev->dev);
@@ -374,8 +351,6 @@ static int tegra20_spdif_platform_remove(struct platform_device *pdev)
374 tegra_pcm_platform_unregister(&pdev->dev); 351 tegra_pcm_platform_unregister(&pdev->dev);
375 snd_soc_unregister_component(&pdev->dev); 352 snd_soc_unregister_component(&pdev->dev);
376 353
377 clk_put(spdif->clk_spdif_out);
378
379 return 0; 354 return 0;
380} 355}
381 356