kirkwood-i2s.c (54c1e27d8a683e325a8f5f350a4b79e44bbef46d) | kirkwood-i2s.c (eb63231830360f5acfea5dd2b545d7a14476bc3a) |
---|---|
1/* 2 * kirkwood-i2s.c 3 * 4 * (c) 2010 Arnaud Patard <apatard@mandriva.com> 5 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the --- 8 unchanged lines hidden (view full) --- 17#include <linux/slab.h> 18#include <linux/mbus.h> 19#include <linux/delay.h> 20#include <linux/clk.h> 21#include <sound/pcm.h> 22#include <sound/pcm_params.h> 23#include <sound/soc.h> 24#include <linux/platform_data/asoc-kirkwood.h> | 1/* 2 * kirkwood-i2s.c 3 * 4 * (c) 2010 Arnaud Patard <apatard@mandriva.com> 5 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the --- 8 unchanged lines hidden (view full) --- 17#include <linux/slab.h> 18#include <linux/mbus.h> 19#include <linux/delay.h> 20#include <linux/clk.h> 21#include <sound/pcm.h> 22#include <sound/pcm_params.h> 23#include <sound/soc.h> 24#include <linux/platform_data/asoc-kirkwood.h> |
25#include <linux/of.h> 26 |
|
25#include "kirkwood.h" 26 27#define DRV_NAME "mvebu-audio" 28 29#define KIRKWOOD_I2S_FORMATS \ 30 (SNDRV_PCM_FMTBIT_S16_LE | \ 31 SNDRV_PCM_FMTBIT_S24_LE | \ 32 SNDRV_PCM_FMTBIT_S32_LE) --- 415 unchanged lines hidden (view full) --- 448}; 449 450static int kirkwood_i2s_dev_probe(struct platform_device *pdev) 451{ 452 struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; 453 struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai; 454 struct kirkwood_dma_data *priv; 455 struct resource *mem; | 27#include "kirkwood.h" 28 29#define DRV_NAME "mvebu-audio" 30 31#define KIRKWOOD_I2S_FORMATS \ 32 (SNDRV_PCM_FMTBIT_S16_LE | \ 33 SNDRV_PCM_FMTBIT_S24_LE | \ 34 SNDRV_PCM_FMTBIT_S32_LE) --- 415 unchanged lines hidden (view full) --- 450}; 451 452static int kirkwood_i2s_dev_probe(struct platform_device *pdev) 453{ 454 struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; 455 struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai; 456 struct kirkwood_dma_data *priv; 457 struct resource *mem; |
458 struct device_node *np = pdev->dev.of_node; |
|
456 int err; 457 458 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 459 if (!priv) { 460 dev_err(&pdev->dev, "allocation failed\n"); 461 return -ENOMEM; 462 } 463 dev_set_drvdata(&pdev->dev, priv); --- 4 unchanged lines hidden (view full) --- 468 return PTR_ERR(priv->io); 469 470 priv->irq = platform_get_irq(pdev, 0); 471 if (priv->irq <= 0) { 472 dev_err(&pdev->dev, "platform_get_irq failed\n"); 473 return -ENXIO; 474 } 475 | 459 int err; 460 461 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 462 if (!priv) { 463 dev_err(&pdev->dev, "allocation failed\n"); 464 return -ENOMEM; 465 } 466 dev_set_drvdata(&pdev->dev, priv); --- 4 unchanged lines hidden (view full) --- 471 return PTR_ERR(priv->io); 472 473 priv->irq = platform_get_irq(pdev, 0); 474 if (priv->irq <= 0) { 475 dev_err(&pdev->dev, "platform_get_irq failed\n"); 476 return -ENXIO; 477 } 478 |
476 if (!data) { 477 dev_err(&pdev->dev, "no platform data ?!\n"); | 479 if (np) { 480 priv->burst = 128; /* might be 32 or 128 */ 481 } else if (data) { 482 priv->burst = data->burst; 483 } else { 484 dev_err(&pdev->dev, "no DT nor platform data ?!\n"); |
478 return -EINVAL; 479 } 480 | 485 return -EINVAL; 486 } 487 |
481 priv->burst = data->burst; 482 483 priv->clk = devm_clk_get(&pdev->dev, NULL); | 488 priv->clk = devm_clk_get(&pdev->dev, np ? "internal" : NULL); |
484 if (IS_ERR(priv->clk)) { 485 dev_err(&pdev->dev, "no clock\n"); 486 return PTR_ERR(priv->clk); 487 } 488 489 err = clk_prepare_enable(priv->clk); 490 if (err < 0) 491 return err; --- 10 unchanged lines hidden (view full) --- 502 } 503 } 504 505 /* Some sensible defaults - this reflects the powerup values */ 506 priv->ctl_play = KIRKWOOD_PLAYCTL_SIZE_24; 507 priv->ctl_rec = KIRKWOOD_RECCTL_SIZE_24; 508 509 /* Select the burst size */ | 489 if (IS_ERR(priv->clk)) { 490 dev_err(&pdev->dev, "no clock\n"); 491 return PTR_ERR(priv->clk); 492 } 493 494 err = clk_prepare_enable(priv->clk); 495 if (err < 0) 496 return err; --- 10 unchanged lines hidden (view full) --- 507 } 508 } 509 510 /* Some sensible defaults - this reflects the powerup values */ 511 priv->ctl_play = KIRKWOOD_PLAYCTL_SIZE_24; 512 priv->ctl_rec = KIRKWOOD_RECCTL_SIZE_24; 513 514 /* Select the burst size */ |
510 if (data->burst == 32) { | 515 if (priv->burst == 32) { |
511 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_32; 512 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_32; 513 } else { 514 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_128; 515 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; 516 } 517 518 err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, --- 28 unchanged lines hidden (view full) --- 547 548 if (!IS_ERR(priv->extclk)) 549 clk_disable_unprepare(priv->extclk); 550 clk_disable_unprepare(priv->clk); 551 552 return 0; 553} 554 | 516 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_32; 517 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_32; 518 } else { 519 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_128; 520 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; 521 } 522 523 err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, --- 28 unchanged lines hidden (view full) --- 552 553 if (!IS_ERR(priv->extclk)) 554 clk_disable_unprepare(priv->extclk); 555 clk_disable_unprepare(priv->clk); 556 557 return 0; 558} 559 |
560#ifdef CONFIG_OF 561static struct of_device_id mvebu_audio_of_match[] = { 562 { .compatible = "marvell,mvebu-audio" }, 563 { } 564}; 565MODULE_DEVICE_TABLE(of, mvebu_audio_of_match); 566#endif 567 |
|
555static struct platform_driver kirkwood_i2s_driver = { 556 .probe = kirkwood_i2s_dev_probe, 557 .remove = kirkwood_i2s_dev_remove, 558 .driver = { 559 .name = DRV_NAME, 560 .owner = THIS_MODULE, | 568static struct platform_driver kirkwood_i2s_driver = { 569 .probe = kirkwood_i2s_dev_probe, 570 .remove = kirkwood_i2s_dev_remove, 571 .driver = { 572 .name = DRV_NAME, 573 .owner = THIS_MODULE, |
574 .of_match_table = of_match_ptr(mvebu_audio_of_match), |
|
561 }, 562}; 563 564module_platform_driver(kirkwood_i2s_driver); 565 566/* Module information */ 567MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>"); 568MODULE_DESCRIPTION("Kirkwood I2S SoC Interface"); 569MODULE_LICENSE("GPL"); 570MODULE_ALIAS("platform:mvebu-audio"); | 575 }, 576}; 577 578module_platform_driver(kirkwood_i2s_driver); 579 580/* Module information */ 581MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>"); 582MODULE_DESCRIPTION("Kirkwood I2S SoC Interface"); 583MODULE_LICENSE("GPL"); 584MODULE_ALIAS("platform:mvebu-audio"); |