[alsa-devel] [PATCH V2 0/6] ARM/ASoC: Davinci: Add Device Tree Support
This patch-set is a cumulative of below tasks 1. Split asp header into platform and audio specific Davinci driver is shared by few OMAP platforms (like TI81xx, AM335x). Splitting asp header into Davinci platform specific and Audio specific helps to share them across platforms.
2. Add DT support for Davinci Audio Module (McASP, machine, pcm & Codec)
This patch was tested on AM18x Board (Tested to check if the commits doesn't break on compile or runtime) and is based on repo at http://git.kernel.org/?p=linux/kernel/git/broonie/sound.git; a=shortlog;h=refs/heads/for-3.7 (v3.6-rc2)
Note: Matt Porter from TI is working on DMA engine conversion of DaVinci EDMA support and DT conversion of DMA parts will be taken up post that is complete. Since Audio requires DMA to work, this patch set does not yet provide complete functionality required to use sound on DT-based platforms, but is a step towards that direction.
Changes from V1: - Instanciate seudo-device (davinci-pcm) directly from DAI driver rather than having a separate virtual-device registered - add more explanation to DT parameters - Change DT parameter from "ti,codec-clock" to "ti,codec-clock-rate" - use standard DT GPIO reference by phandle to populate gpio based DT parameters - Dont return err if some DT parameters are missing. They will be treated as 0. - Through Error warning if num-serializer != "serial-dir" array size - Coding Style correction
Hebbar, Gururaja (6): ASoC: davinci: davinci-pcm does not need to be a plaform_driver ARM: Davinci: Remove references to davinci pcm ASoC/ARM: Davinci: McASP: split asp header into platform and audio specific ASoC: Davinci: McASP: add device tree support for McASP ASoC: Davinci: machine: Add device tree binding ASoC: tlv320aic3x: Add device tree bindings
.../bindings/sound/davinci-evm-audio.txt | 63 ++++++ .../bindings/sound/davinci-mcasp-audio.txt | 44 +++++ .../devicetree/bindings/sound/tlv320aic3x.txt | 20 ++ arch/arm/mach-davinci/asp.h | 49 +++++ arch/arm/mach-davinci/davinci.h | 3 +- arch/arm/mach-davinci/devices-da8xx.c | 8 +- arch/arm/mach-davinci/devices.c | 11 - arch/arm/mach-davinci/dm355.c | 2 +- arch/arm/mach-davinci/dm365.c | 2 +- arch/arm/mach-davinci/dm644x.c | 2 +- arch/arm/mach-davinci/dm646x.c | 2 +- arch/arm/mach-davinci/include/mach/da8xx.h | 2 +- .../linux/platform_data/davinci_asp.h | 73 ++----- sound/soc/codecs/tlv320aic3x.c | 31 +++ sound/soc/davinci/davinci-evm.c | 203 +++++++++++++++++--- sound/soc/davinci/davinci-i2s.c | 13 +- sound/soc/davinci/davinci-mcasp.c | 134 +++++++++++++- sound/soc/davinci/davinci-mcasp.h | 3 +- sound/soc/davinci/davinci-pcm.c | 24 +-- sound/soc/davinci/davinci-pcm.h | 6 +- sound/soc/davinci/davinci-sffsdr.c | 2 +- sound/soc/davinci/davinci-vcif.c | 8 + 22 files changed, 573 insertions(+), 132 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/davinci-evm-audio.txt create mode 100644 Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt create mode 100644 Documentation/devicetree/bindings/sound/tlv320aic3x.txt create mode 100644 arch/arm/mach-davinci/asp.h rename arch/arm/mach-davinci/include/mach/asp.h => include/linux/platform_data/davinci_asp.h (56%)
Same as the commit 518de86 (ASoC: tegra: register 'platform' from DAIs, get rid of pdev). It makes davinci-pcm not a platform_driver but helper to register "platform", so that the platform_device for davinci-pcm can be saved completely.
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com --- Changes from V1: - New Commit. Instanciate seudo-device (davinci-pcm) directly from DAI driver rather than having a separate virtual-device registered
:100644 100644 c80c20a... 4b37e2a... M sound/soc/davinci/davinci-evm.c :100644 100644 0a74b95... 407df72... M sound/soc/davinci/davinci-i2s.c :100644 100644 6a2c54c... 34ee2f1... M sound/soc/davinci/davinci-mcasp.c :100644 100644 97d77b2... 4b70828... M sound/soc/davinci/davinci-pcm.c :100644 100644 c0d6c9b... 5e55164... M sound/soc/davinci/davinci-pcm.h :100644 100644 f71175b... 5be65aa... M sound/soc/davinci/davinci-sffsdr.c :100644 100644 da030ff... 07bde2e... M sound/soc/davinci/davinci-vcif.c sound/soc/davinci/davinci-evm.c | 15 ++++++++------- sound/soc/davinci/davinci-i2s.c | 10 ++++++++++ sound/soc/davinci/davinci-mcasp.c | 10 ++++++++++ sound/soc/davinci/davinci-pcm.c | 23 ++++++----------------- sound/soc/davinci/davinci-pcm.h | 3 +++ sound/soc/davinci/davinci-sffsdr.c | 2 +- sound/soc/davinci/davinci-vcif.c | 8 ++++++++ 7 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index c80c20a..4b37e2a 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -159,7 +159,7 @@ static struct snd_soc_dai_link dm6446_evm_dai = { .cpu_dai_name = "davinci-mcbsp", .codec_dai_name = "tlv320aic3x-hifi", .codec_name = "tlv320aic3x-codec.1-001b", - .platform_name = "davinci-pcm-audio", + .platform_name = "davinci-mcbsp", .init = evm_aic3x_init, .ops = &evm_ops, }; @@ -170,7 +170,7 @@ static struct snd_soc_dai_link dm355_evm_dai = { .cpu_dai_name = "davinci-mcbsp.1", .codec_dai_name = "tlv320aic3x-hifi", .codec_name = "tlv320aic3x-codec.1-001b", - .platform_name = "davinci-pcm-audio", + .platform_name = "davinci-mcbsp.1", .init = evm_aic3x_init, .ops = &evm_ops, }; @@ -184,14 +184,15 @@ static struct snd_soc_dai_link dm365_evm_dai = { .init = evm_aic3x_init, .codec_name = "tlv320aic3x-codec.1-0018", .ops = &evm_ops, + .platform_name = "davinci-mcbsp", #elif defined(CONFIG_SND_DM365_VOICE_CODEC) .name = "Voice Codec - CQ93VC", .stream_name = "CQ93", .cpu_dai_name = "davinci-vcif", .codec_dai_name = "cq93vc-hifi", .codec_name = "cq93vc-codec", + .platform_name = "avinci-vcif", #endif - .platform_name = "davinci-pcm-audio", };
static struct snd_soc_dai_link dm6467_evm_dai[] = { @@ -200,7 +201,7 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = { .stream_name = "AIC3X", .cpu_dai_name= "davinci-mcasp.0", .codec_dai_name = "tlv320aic3x-hifi", - .platform_name ="davinci-pcm-audio", + .platform_name = "davinci-mcasp.0", .codec_name = "tlv320aic3x-codec.0-001a", .init = evm_aic3x_init, .ops = &evm_ops, @@ -211,7 +212,7 @@ static struct snd_soc_dai_link dm6467_evm_dai[] = { .cpu_dai_name= "davinci-mcasp.1", .codec_dai_name = "dit-hifi", .codec_name = "spdif_dit", - .platform_name = "davinci-pcm-audio", + .platform_name = "davinci-mcasp.1", .ops = &evm_spdif_ops, }, }; @@ -222,7 +223,7 @@ static struct snd_soc_dai_link da830_evm_dai = { .cpu_dai_name = "davinci-mcasp.1", .codec_dai_name = "tlv320aic3x-hifi", .codec_name = "tlv320aic3x-codec.1-0018", - .platform_name = "davinci-pcm-audio", + .platform_name = "davinci-mcasp.1", .init = evm_aic3x_init, .ops = &evm_ops, }; @@ -233,7 +234,7 @@ static struct snd_soc_dai_link da850_evm_dai = { .cpu_dai_name= "davinci-mcasp.0", .codec_dai_name = "tlv320aic3x-hifi", .codec_name = "tlv320aic3x-codec.1-0018", - .platform_name = "davinci-pcm-audio", + .platform_name = "davinci-mcasp.0", .init = evm_aic3x_init, .ops = &evm_ops, }; diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 0a74b95..407df72 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -732,8 +732,16 @@ static int davinci_i2s_probe(struct platform_device *pdev) if (ret != 0) goto err_release_clk;
+ ret = davinci_soc_platform_register(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "register PCM failed: %d\n", ret); + goto err_unregister_dai; + } + return 0;
+err_unregister_dai: + snd_soc_unregister_dai(&pdev->dev); err_release_clk: clk_disable(dev->clk); clk_put(dev->clk); @@ -745,6 +753,8 @@ static int davinci_i2s_remove(struct platform_device *pdev) struct davinci_mcbsp_dev *dev = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_dai(&pdev->dev); + davinci_soc_platform_unregister(&pdev->dev); + clk_disable(dev->clk); clk_put(dev->clk); dev->clk = NULL; diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 6a2c54c..34ee2f1 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -951,8 +951,17 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
if (ret != 0) goto err_release_clk; + + ret = davinci_soc_platform_register(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "register PCM failed: %d\n", ret); + goto err_unregister_dai; + } + return 0;
+err_unregister_dai: + snd_soc_unregister_dai(&pdev->dev); err_release_clk: pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -963,6 +972,7 @@ static int davinci_mcasp_remove(struct platform_device *pdev) {
snd_soc_unregister_dai(&pdev->dev); + davinci_soc_platform_unregister(&pdev->dev);
pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 97d77b2..4b70828 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c @@ -864,28 +864,17 @@ static struct snd_soc_platform_driver davinci_soc_platform = { .pcm_free = davinci_pcm_free, };
-static int __devinit davinci_soc_platform_probe(struct platform_device *pdev) +int davinci_soc_platform_register(struct device *dev) { - return snd_soc_register_platform(&pdev->dev, &davinci_soc_platform); + return snd_soc_register_platform(dev, &davinci_soc_platform); } +EXPORT_SYMBOL_GPL(davinci_soc_platform_register);
-static int __devexit davinci_soc_platform_remove(struct platform_device *pdev) +void davinci_soc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(&pdev->dev); - return 0; + snd_soc_unregister_platform(dev); } - -static struct platform_driver davinci_pcm_driver = { - .driver = { - .name = "davinci-pcm-audio", - .owner = THIS_MODULE, - }, - - .probe = davinci_soc_platform_probe, - .remove = __devexit_p(davinci_soc_platform_remove), -}; - -module_platform_driver(davinci_pcm_driver); +EXPORT_SYMBOL_GPL(davinci_soc_platform_unregister);
MODULE_AUTHOR("Vladimir Barinov"); MODULE_DESCRIPTION("TI DAVINCI PCM DMA module"); diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h index c0d6c9b..5e55164 100644 --- a/sound/soc/davinci/davinci-pcm.h +++ b/sound/soc/davinci/davinci-pcm.h @@ -28,4 +28,7 @@ struct davinci_pcm_dma_params { unsigned int fifo_level; };
+int davinci_soc_platform_register(struct device *dev); +void davinci_soc_platform_unregister(struct device *dev); + #endif diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c index f71175b..5be65aa 100644 --- a/sound/soc/davinci/davinci-sffsdr.c +++ b/sound/soc/davinci/davinci-sffsdr.c @@ -86,7 +86,7 @@ static struct snd_soc_dai_link sffsdr_dai = { .cpu_dai_name = "davinci-mcbsp", .codec_dai_name = "pcm3008-hifi", .codec_name = "pcm3008-codec", - .platform_name = "davinci-pcm-audio", + .platform_name = "davinci-mcbsp", .ops = &sffsdr_ops, };
diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c index da030ff..07bde2e 100644 --- a/sound/soc/davinci/davinci-vcif.c +++ b/sound/soc/davinci/davinci-vcif.c @@ -240,12 +240,20 @@ static int davinci_vcif_probe(struct platform_device *pdev) return ret; }
+ ret = davinci_soc_platform_register(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "register PCM failed: %d\n", ret); + snd_soc_unregister_dai(&pdev->dev); + return ret; + } + return 0; }
static int davinci_vcif_remove(struct platform_device *pdev) { snd_soc_unregister_dai(&pdev->dev); + davinci_soc_platform_unregister(&pdev->dev);
return 0; }
On Mon, Aug 27, 2012 at 06:56:39PM +0530, Hebbar, Gururaja wrote:
Same as the commit 518de86 (ASoC: tegra: register 'platform' from DAIs, get rid of pdev). It makes davinci-pcm not a platform_driver but helper to register "platform", so that the platform_device for davinci-pcm can be saved completely.
Applied, thanks.
On Mon, Aug 27, 2012 at 06:56:39PM +0530, Hebbar, Gururaja wrote:
Same as the commit 518de86 (ASoC: tegra: register 'platform' from DAIs, get rid of pdev). It makes davinci-pcm not a platform_driver but helper to register "platform", so that the platform_device for davinci-pcm can be saved completely.
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com
Changes from V1:
- New Commit. Instanciate seudo-device (davinci-pcm) directly from DAI driver rather than having a separate virtual-device registered
:100644 100644 c80c20a... 4b37e2a... M sound/soc/davinci/davinci-evm.c :100644 100644 0a74b95... 407df72... M sound/soc/davinci/davinci-i2s.c :100644 100644 6a2c54c... 34ee2f1... M sound/soc/davinci/davinci-mcasp.c :100644 100644 97d77b2... 4b70828... M sound/soc/davinci/davinci-pcm.c :100644 100644 c0d6c9b... 5e55164... M sound/soc/davinci/davinci-pcm.h :100644 100644 f71175b... 5be65aa... M sound/soc/davinci/davinci-sffsdr.c :100644 100644 da030ff... 07bde2e... M sound/soc/davinci/davinci-vcif.c sound/soc/davinci/davinci-evm.c | 15 ++++++++------- sound/soc/davinci/davinci-i2s.c | 10 ++++++++++ sound/soc/davinci/davinci-mcasp.c | 10 ++++++++++ sound/soc/davinci/davinci-pcm.c | 23 ++++++----------------- sound/soc/davinci/davinci-pcm.h | 3 +++ sound/soc/davinci/davinci-sffsdr.c | 2 +- sound/soc/davinci/davinci-vcif.c | 8 ++++++++ 7 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index c80c20a..4b37e2a 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -159,7 +159,7 @@ static struct snd_soc_dai_link dm6446_evm_dai = { .cpu_dai_name = "davinci-mcbsp", .codec_dai_name = "tlv320aic3x-hifi", .codec_name = "tlv320aic3x-codec.1-001b",
- .platform_name = "davinci-pcm-audio",
- .platform_name = "davinci-mcbsp", .init = evm_aic3x_init, .ops = &evm_ops,
}; @@ -170,7 +170,7 @@ static struct snd_soc_dai_link dm355_evm_dai = { .cpu_dai_name = "davinci-mcbsp.1", .codec_dai_name = "tlv320aic3x-hifi", .codec_name = "tlv320aic3x-codec.1-001b",
- .platform_name = "davinci-pcm-audio",
- .platform_name = "davinci-mcbsp.1", .init = evm_aic3x_init, .ops = &evm_ops,
}; @@ -184,14 +184,15 @@ static struct snd_soc_dai_link dm365_evm_dai = { .init = evm_aic3x_init, .codec_name = "tlv320aic3x-codec.1-0018", .ops = &evm_ops,
- .platform_name = "davinci-mcbsp",
#elif defined(CONFIG_SND_DM365_VOICE_CODEC) .name = "Voice Codec - CQ93VC", .stream_name = "CQ93", .cpu_dai_name = "davinci-vcif", .codec_dai_name = "cq93vc-hifi", .codec_name = "cq93vc-codec",
- .platform_name = "avinci-vcif",
Typo?
On Wed, Aug 29, 2012 at 11:55:34, Sergey Vlasov wrote:
On Mon, Aug 27, 2012 at 06:56:39PM +0530, Hebbar, Gururaja wrote:
Same as the commit 518de86 (ASoC: tegra: register 'platform' from DAIs, get rid of pdev). It makes davinci-pcm not a platform_driver but helper to register "platform", so that the platform_device for davinci-pcm can be saved completely.
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com
Changes from V1:
- New Commit. Instanciate seudo-device (davinci-pcm) directly from DAI driver rather than having a separate virtual-device registered
:100644 100644 c80c20a... 4b37e2a... M sound/soc/davinci/davinci-evm.c :100644 100644 0a74b95... 407df72... M sound/soc/davinci/davinci-i2s.c :100644 100644 6a2c54c... 34ee2f1... M sound/soc/davinci/davinci-mcasp.c
...snip... ...snip...
.name = "Voice Codec - CQ93VC", .stream_name = "CQ93", .cpu_dai_name = "davinci-vcif", .codec_dai_name = "cq93vc-hifi", .codec_name = "cq93vc-codec",
- .platform_name = "avinci-vcif",
Typo?
Oops. Sorry. Will send back a corrected patch ASAP
Regards, Gururaja
Since davinci-pcm is no more a platform_driver but helper to register "platform" pcm driver, remove davinci-pcm device registration
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com --- Changes from V1: - New Commit.
:100644 100644 783eab6... 4735d64... M arch/arm/mach-davinci/devices-da8xx.c :100644 100644 d2f96662.. 70056fb... M arch/arm/mach-davinci/devices.c arch/arm/mach-davinci/devices-da8xx.c | 7 ------- arch/arm/mach-davinci/devices.c | 11 ----------- 2 files changed, 0 insertions(+), 18 deletions(-)
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 783eab6..4735d64 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -505,15 +505,8 @@ static struct platform_device da850_mcasp_device = { .resource = da850_mcasp_resources, };
-static struct platform_device davinci_pcm_device = { - .name = "davinci-pcm-audio", - .id = -1, -}; - void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) { - platform_device_register(&davinci_pcm_device); - /* DA830/OMAP-L137 has 3 instances of McASP */ if (cpu_is_davinci_da830() && id == 1) { da830_mcasp1_device.dev.platform_data = pdata; diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c index d2f9666..70056fb 100644 --- a/arch/arm/mach-davinci/devices.c +++ b/arch/arm/mach-davinci/devices.c @@ -313,16 +313,6 @@ static void davinci_init_wdt(void)
/*-------------------------------------------------------------------------*/
-static struct platform_device davinci_pcm_device = { - .name = "davinci-pcm-audio", - .id = -1, -}; - -static void davinci_init_pcm(void) -{ - platform_device_register(&davinci_pcm_device); -} - /*-------------------------------------------------------------------------*/
struct davinci_timer_instance davinci_timer_instance[2] = { @@ -345,7 +335,6 @@ static int __init davinci_init_devices(void) /* please keep these calls, and their implementations above, * in alphabetical order so they're easier to sort through. */ - davinci_init_pcm(); davinci_init_wdt();
return 0;
On Mon, Aug 27, 2012 at 06:56:40PM +0530, Hebbar, Gururaja wrote:
Since davinci-pcm is no more a platform_driver but helper to register "platform" pcm driver, remove davinci-pcm device registration
Applied, thanks.
Davinci McASP header & driver are shared by few OMAP platforms (like TI81xx, AM335x). Splitting asp header into Davinci platform specific header and Audio specific header helps to share them across platforms.
Audio specific defines is moved to to common <linux/platform_data/davinci_asp.h> so that the header can be accessed by all related platforms.
While here, correct the header usage (remove multiple header re-definitions and unused headers) and remove platform names from structures comments and enum. Also some some coding style errors.
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com Acked-by: Vaibhav Bedia vaibhav.bedia@ti.com
--- Changes from V1: - Coding Style Correction
:000000 100644 0000000... d9b2acd... A arch/arm/mach-davinci/asp.h :100644 100644 8db0fc6... 8661b20... M arch/arm/mach-davinci/davinci.h :100644 100644 4735d64... bd2f72b... M arch/arm/mach-davinci/devices-da8xx.c :100644 100644 678cd99... e47a3f0... M arch/arm/mach-davinci/dm355.c :100644 100644 a50d49de.. f473745... M arch/arm/mach-davinci/dm365.c :100644 100644 c8b8666... 0755d46... M arch/arm/mach-davinci/dm644x.c :100644 100644 9eb87c1... 97c0f8e... M arch/arm/mach-davinci/dm646x.c :100644 100644 a2f1f27... c74a6ab... M arch/arm/mach-davinci/include/mach/da8xx.h :100644 100644 9aa2409... 79c26aa... R056 arch/arm/mach-davinci/include/mach/asp.h include/linux/platform_data/davinci_asp.h :100644 100644 4b37e2a... ab0ad45... M sound/soc/davinci/davinci-evm.c :100644 100644 407df72... 8218312... M sound/soc/davinci/davinci-i2s.c :100644 100644 51479f9... 0de9ed6... M sound/soc/davinci/davinci-mcasp.h :100644 100644 4b70828... 93ea3bf... M sound/soc/davinci/davinci-pcm.c :100644 100644 5e55164... fc4d01c... M sound/soc/davinci/davinci-pcm.h arch/arm/mach-davinci/asp.h | 49 +++++++++++++ arch/arm/mach-davinci/davinci.h | 3 +- arch/arm/mach-davinci/devices-da8xx.c | 1 + arch/arm/mach-davinci/dm355.c | 2 +- arch/arm/mach-davinci/dm365.c | 2 +- arch/arm/mach-davinci/dm644x.c | 2 +- arch/arm/mach-davinci/dm646x.c | 2 +- arch/arm/mach-davinci/include/mach/da8xx.h | 2 +- .../linux/platform_data/davinci_asp.h | 73 ++++++-------------- sound/soc/davinci/davinci-evm.c | 3 - sound/soc/davinci/davinci-i2s.c | 3 +- sound/soc/davinci/davinci-mcasp.h | 3 +- sound/soc/davinci/davinci-pcm.c | 1 - sound/soc/davinci/davinci-pcm.h | 3 +- 14 files changed, 81 insertions(+), 68 deletions(-)
diff --git a/arch/arm/mach-davinci/asp.h b/arch/arm/mach-davinci/asp.h new file mode 100644 index 0000000..d9b2acd --- /dev/null +++ b/arch/arm/mach-davinci/asp.h @@ -0,0 +1,49 @@ +/* + * TI DaVinci Audio definitions + */ +#ifndef __ASM_ARCH_DAVINCI_ASP_H +#define __ASM_ARCH_DAVINCI_ASP_H + +/* Bases of dm644x and dm355 register banks */ +#define DAVINCI_ASP0_BASE 0x01E02000 +#define DAVINCI_ASP1_BASE 0x01E04000 + +/* Bases of dm365 register banks */ +#define DAVINCI_DM365_ASP0_BASE 0x01D02000 + +/* Bases of dm646x register banks */ +#define DAVINCI_DM646X_MCASP0_REG_BASE 0x01D01000 +#define DAVINCI_DM646X_MCASP1_REG_BASE 0x01D01800 + +/* Bases of da850/da830 McASP0 register banks */ +#define DAVINCI_DA8XX_MCASP0_REG_BASE 0x01D00000 + +/* Bases of da830 McASP1 register banks */ +#define DAVINCI_DA830_MCASP1_REG_BASE 0x01D04000 + +/* EDMA channels of dm644x and dm355 */ +#define DAVINCI_DMA_ASP0_TX 2 +#define DAVINCI_DMA_ASP0_RX 3 +#define DAVINCI_DMA_ASP1_TX 8 +#define DAVINCI_DMA_ASP1_RX 9 + +/* EDMA channels of dm646x */ +#define DAVINCI_DM646X_DMA_MCASP0_AXEVT0 6 +#define DAVINCI_DM646X_DMA_MCASP0_AREVT0 9 +#define DAVINCI_DM646X_DMA_MCASP1_AXEVT1 12 + +/* EDMA channels of da850/da830 McASP0 */ +#define DAVINCI_DA8XX_DMA_MCASP0_AREVT 0 +#define DAVINCI_DA8XX_DMA_MCASP0_AXEVT 1 + +/* EDMA channels of da830 McASP1 */ +#define DAVINCI_DA830_DMA_MCASP1_AREVT 2 +#define DAVINCI_DA830_DMA_MCASP1_AXEVT 3 + +/* Interrupts */ +#define DAVINCI_ASP0_RX_INT IRQ_MBRINT +#define DAVINCI_ASP0_TX_INT IRQ_MBXINT +#define DAVINCI_ASP1_RX_INT IRQ_MBRINT +#define DAVINCI_ASP1_TX_INT IRQ_MBXINT + +#endif /* __ASM_ARCH_DAVINCI_ASP_H */ diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h index 8db0fc6..8661b20 100644 --- a/arch/arm/mach-davinci/davinci.h +++ b/arch/arm/mach-davinci/davinci.h @@ -22,10 +22,11 @@ #include <linux/davinci_emac.h> #include <linux/platform_device.h> #include <linux/spi/spi.h> +#include <linux/platform_data/davinci_asp.h>
-#include <mach/asp.h> #include <mach/keyscan.h> #include <mach/hardware.h> +#include <mach/edma.h>
#include <media/davinci/vpfe_capture.h> #include <media/davinci/vpif_types.h> diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 4735d64..bd2f72b 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -24,6 +24,7 @@ #include <mach/cpuidle.h>
#include "clock.h" +#include "asp.h"
#define DA8XX_TPCC_BASE 0x01c00000 #define DA8XX_TPTC0_BASE 0x01c08000 diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index 678cd99..e47a3f0 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c @@ -26,13 +26,13 @@ #include <mach/time.h> #include <mach/serial.h> #include <mach/common.h> -#include <mach/asp.h> #include <mach/spi.h> #include <mach/gpio-davinci.h>
#include "davinci.h" #include "clock.h" #include "mux.h" +#include "asp.h"
#define DM355_UART2_BASE (IO_PHYS + 0x206000)
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index a50d49d..f473745 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -29,7 +29,6 @@ #include <mach/time.h> #include <mach/serial.h> #include <mach/common.h> -#include <mach/asp.h> #include <mach/keyscan.h> #include <mach/spi.h> #include <mach/gpio-davinci.h> @@ -37,6 +36,7 @@ #include "davinci.h" #include "clock.h" #include "mux.h" +#include "asp.h"
#define DM365_REF_FREQ 24000000 /* 24 MHz on the DM365 EVM */
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index c8b8666..0755d46 100644 --- a/arch/arm/mach-davinci/dm644x.c +++ b/arch/arm/mach-davinci/dm644x.c @@ -23,12 +23,12 @@ #include <mach/time.h> #include <mach/serial.h> #include <mach/common.h> -#include <mach/asp.h> #include <mach/gpio-davinci.h>
#include "davinci.h" #include "clock.h" #include "mux.h" +#include "asp.h"
/* * Device specific clocks diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 9eb87c1..97c0f8e 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c @@ -24,12 +24,12 @@ #include <mach/time.h> #include <mach/serial.h> #include <mach/common.h> -#include <mach/asp.h> #include <mach/gpio-davinci.h>
#include "davinci.h" #include "clock.h" #include "mux.h" +#include "asp.h"
#define DAVINCI_VPIF_BASE (0x01C12000)
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h index a2f1f27..c74a6ab 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h @@ -16,11 +16,11 @@ #include <linux/platform_device.h> #include <linux/davinci_emac.h> #include <linux/spi/spi.h> +#include <linux/platform_data/davinci_asp.h>
#include <mach/serial.h> #include <mach/edma.h> #include <mach/i2c.h> -#include <mach/asp.h> #include <mach/mmc.h> #include <mach/usb.h> #include <mach/pm.h> diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/include/linux/platform_data/davinci_asp.h similarity index 56% rename from arch/arm/mach-davinci/include/mach/asp.h rename to include/linux/platform_data/davinci_asp.h index 9aa2409..79c26aa 100644 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ b/include/linux/platform_data/davinci_asp.h @@ -1,59 +1,26 @@ /* - * <mach/asp.h> - DaVinci Audio Serial Port support + * TI DaVinci Audio Serial Port support + * + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ -#ifndef __ASM_ARCH_DAVINCI_ASP_H -#define __ASM_ARCH_DAVINCI_ASP_H
-#include <mach/irqs.h> -#include <mach/edma.h> - -/* Bases of dm644x and dm355 register banks */ -#define DAVINCI_ASP0_BASE 0x01E02000 -#define DAVINCI_ASP1_BASE 0x01E04000 - -/* Bases of dm365 register banks */ -#define DAVINCI_DM365_ASP0_BASE 0x01D02000 - -/* Bases of dm646x register banks */ -#define DAVINCI_DM646X_MCASP0_REG_BASE 0x01D01000 -#define DAVINCI_DM646X_MCASP1_REG_BASE 0x01D01800 - -/* Bases of da850/da830 McASP0 register banks */ -#define DAVINCI_DA8XX_MCASP0_REG_BASE 0x01D00000 - -/* Bases of da830 McASP1 register banks */ -#define DAVINCI_DA830_MCASP1_REG_BASE 0x01D04000 - -/* EDMA channels of dm644x and dm355 */ -#define DAVINCI_DMA_ASP0_TX 2 -#define DAVINCI_DMA_ASP0_RX 3 -#define DAVINCI_DMA_ASP1_TX 8 -#define DAVINCI_DMA_ASP1_RX 9 - -/* EDMA channels of dm646x */ -#define DAVINCI_DM646X_DMA_MCASP0_AXEVT0 6 -#define DAVINCI_DM646X_DMA_MCASP0_AREVT0 9 -#define DAVINCI_DM646X_DMA_MCASP1_AXEVT1 12 - -/* EDMA channels of da850/da830 McASP0 */ -#define DAVINCI_DA8XX_DMA_MCASP0_AREVT 0 -#define DAVINCI_DA8XX_DMA_MCASP0_AXEVT 1 - -/* EDMA channels of da830 McASP1 */ -#define DAVINCI_DA830_DMA_MCASP1_AREVT 2 -#define DAVINCI_DA830_DMA_MCASP1_AXEVT 3 - -/* Interrupts */ -#define DAVINCI_ASP0_RX_INT IRQ_MBRINT -#define DAVINCI_ASP0_TX_INT IRQ_MBXINT -#define DAVINCI_ASP1_RX_INT IRQ_MBRINT -#define DAVINCI_ASP1_TX_INT IRQ_MBXINT +#ifndef __DAVINCI_ASP_H +#define __DAVINCI_ASP_H
struct snd_platform_data { u32 tx_dma_offset; u32 rx_dma_offset; - enum dma_event_q asp_chan_q; /* event queue number for ASP channel */ - enum dma_event_q ram_chan_q; /* event queue number for RAM channel */ + int asp_chan_q; /* event queue number for ASP channel */ + int ram_chan_q; /* event queue number for RAM channel */ unsigned int codec_fmt; /* * Allowing this is more efficient and eliminates left and right swaps @@ -70,7 +37,7 @@ struct snd_platform_data { * and MCBSP_CLKS. * Depending on different hardware connections it is possible * to use this setting to change the behaviour of McBSP - * driver. The dm365_clk_input_pin enum is available for dm365 + * driver. */ int clk_input_pin;
@@ -122,8 +89,8 @@ enum { MCASP_VERSION_2, /* DA8xx/OMAPL1x */ };
-enum dm365_clk_input_pin { - MCBSP_CLKR = 0, /* DM365 */ +enum mcbsp_clk_input_pin { + MCBSP_CLKR = 0, /* as in DM365 */ MCBSP_CLKS, };
@@ -134,4 +101,4 @@ enum dm365_clk_input_pin { #define DAVINCI_MCASP_IIS_MODE 0 #define DAVINCI_MCASP_DIT_MODE 1
-#endif /* __ASM_ARCH_DAVINCI_ASP_H */ +#endif diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 4b37e2a..ab0ad45 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -22,9 +22,6 @@ #include <asm/dma.h> #include <asm/mach-types.h>
-#include <mach/asp.h> -#include <mach/edma.h> - #include "davinci-pcm.h" #include "davinci-i2s.h" #include "davinci-mcasp.h" diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 407df72..8218312 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -16,6 +16,7 @@ #include <linux/delay.h> #include <linux/io.h> #include <linux/clk.h> +#include <linux/platform_data/davinci_asp.h>
#include <sound/core.h> #include <sound/pcm.h> @@ -23,8 +24,6 @@ #include <sound/initval.h> #include <sound/soc.h>
-#include <mach/asp.h> - #include "davinci-pcm.h" #include "davinci-i2s.h"
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index 51479f9..0de9ed6 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h @@ -19,7 +19,8 @@ #define DAVINCI_MCASP_H
#include <linux/io.h> -#include <mach/asp.h> +#include <linux/platform_data/davinci_asp.h> + #include "davinci-pcm.h"
#define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_96000 diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c index 4b70828..93ea3bf 100644 --- a/sound/soc/davinci/davinci-pcm.c +++ b/sound/soc/davinci/davinci-pcm.c @@ -23,7 +23,6 @@ #include <sound/soc.h>
#include <asm/dma.h> -#include <mach/edma.h> #include <mach/sram.h>
#include "davinci-pcm.h" diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h index 5e55164..fc4d01c 100644 --- a/sound/soc/davinci/davinci-pcm.h +++ b/sound/soc/davinci/davinci-pcm.h @@ -12,9 +12,8 @@ #ifndef _DAVINCI_PCM_H #define _DAVINCI_PCM_H
+#include <linux/platform_data/davinci_asp.h> #include <mach/edma.h> -#include <mach/asp.h> -
struct davinci_pcm_dma_params { int channel; /* sync dma channel ID */
On Mon, Aug 27, 2012 at 06:56:41PM +0530, Hebbar, Gururaja wrote:
Davinci McASP header & driver are shared by few OMAP platforms (like TI81xx, AM335x). Splitting asp header into Davinci platform specific header and Audio specific header helps to share them across platforms.
Applied, thanks.
Add device tree probe for McASP driver.
Note: DMA parameters are not populated from DT and will be done later.
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com --- Changes from V1: - add more explanation to DT parameters - Dont return err if some DT parameters are missing. They will be treated as 0. - Through Error warning if num-serializer != "serial-dir" array size
:000000 100644 0000000... e6148ec... A Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt :100644 100644 34ee2f1... c3eae1d... M sound/soc/davinci/davinci-mcasp.c .../bindings/sound/davinci-mcasp-audio.txt | 44 +++++++ sound/soc/davinci/davinci-mcasp.c | 124 +++++++++++++++++++- 2 files changed, 167 insertions(+), 1 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt new file mode 100644 index 0000000..e6148ec --- /dev/null +++ b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt @@ -0,0 +1,44 @@ +Texas Instruments McASP controller + +Required properties: +- compatible : + "ti,dm646x-mcasp-audio" : for DM646x platforms + "ti,da830-mcasp-audio" : for both DA830 & DA850 platforms + +- reg : Should contain McASP registers offset and length +- interrupts : Interrupt number for McASP +- op-mode : I2S/DIT ops mode. +- tdm-slots : Slots for TDM operation. +- num-serializer : Serializers used by McASP. +- serial-dir : A list of serializer pin mode. The list number should be equal + to "num-serializer" parameter. Each entry is a number indication + serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX) + + +Optional properties: + +- ti,hwmods : Must be "mcasp<n>", n is controller instance starting 0 +- tx-num-evt : FIFO levels. +- rx-num-evt : FIFO levels. +- sram-size-playback : size of sram to be allocated during playback +- sram-size-capture : size of sram to be allocated during capture + +Example: + +mcasp0: mcasp0@1d00000 { + compatible = "ti,da830-mcasp-audio"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x100000 0x3000>; + interrupts = <82 83>; + op-mode = <0>; /* MCASP_IIS_MODE */ + tdm-slots = <2>; + num-serializer = <16>; + serial-dir = < + 0 0 0 0 /* 0: INACTIVE, 1: TX, 2: RX */ + 0 0 0 0 + 0 0 0 1 + 2 0 0 0 >; + tx-num-evt = <1>; + rx-num-evt = <1>; +}; diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 34ee2f1..c3eae1d 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -22,6 +22,9 @@ #include <linux/delay.h> #include <linux/io.h> #include <linux/pm_runtime.h> +#include <linux/of.h> +#include <linux/of_platform.h> +#include <linux/of_device.h>
#include <sound/core.h> #include <sound/pcm.h> @@ -862,6 +865,114 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
};
+static const struct of_device_id mcasp_dt_ids[] = { + { + .compatible = "ti,dm646x-mcasp-audio", + .data = (void *)MCASP_VERSION_1, + }, + { + .compatible = "ti,da830-mcasp-audio", + .data = (void *)MCASP_VERSION_2, + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, mcasp_dt_ids); + +static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( + struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct snd_platform_data *pdata = NULL; + const struct of_device_id *match = + of_match_device(of_match_ptr(mcasp_dt_ids), &pdev->dev); + + const u32 *of_serial_dir32; + u8 *of_serial_dir; + u32 val; + int i, ret = 0; + + if (pdev->dev.platform_data) { + pdata = pdev->dev.platform_data; + return pdata; + } else if (match) { + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + ret = -ENOMEM; + goto nodata; + } + } else { + /* control shouldn't reach here. something is wrong */ + ret = -EINVAL; + goto nodata; + } + + if (match->data) + pdata->version = (u8)((int)match->data); + + ret = of_property_read_u32(np, "op-mode", &val); + if (ret >= 0) + pdata->op_mode = val; + + ret = of_property_read_u32(np, "tdm-slots", &val); + if (ret >= 0) + pdata->tdm_slots = val; + + ret = of_property_read_u32(np, "num-serializer", &val); + if (ret >= 0) + pdata->num_serializer = val; + + of_serial_dir32 = of_get_property(np, "serial-dir", &val); + val /= sizeof(u32); + if (val != pdata->num_serializer) { + dev_err(&pdev->dev, + "num-serializer(%d) != serial-dir size(%d)\n", + pdata->num_serializer, val); + ret = -EINVAL; + goto nodata; + } + + if (of_serial_dir32) { + of_serial_dir = devm_kzalloc(&pdev->dev, + (sizeof(*of_serial_dir) * val), + GFP_KERNEL); + if (!of_serial_dir) { + ret = -ENOMEM; + goto nodata; + } + + for (i = 0; i < pdata->num_serializer; i++) + of_serial_dir[i] = be32_to_cpup(&of_serial_dir32[i]); + + pdata->serial_dir = of_serial_dir; + } + + ret = of_property_read_u32(np, "tx-num-evt", &val); + if (ret >= 0) + pdata->txnumevt = val; + + ret = of_property_read_u32(np, "rx-num-evt", &val); + if (ret >= 0) + pdata->rxnumevt = val; + + ret = of_property_read_u32(np, "sram-size-playback", &val); + if (ret >= 0) + pdata->sram_size_playback = val; + + ret = of_property_read_u32(np, "sram-size-capture", &val); + if (ret >= 0) + pdata->sram_size_capture = val; + + return pdata; + +nodata: + if (ret < 0) { + dev_err(&pdev->dev, "Error populating platform data, err %d\n", + ret); + pdata = NULL; + } + return pdata; +} + static int davinci_mcasp_probe(struct platform_device *pdev) { struct davinci_pcm_dma_params *dma_data; @@ -870,11 +981,22 @@ static int davinci_mcasp_probe(struct platform_device *pdev) struct davinci_audio_dev *dev; int ret;
+ if (!pdev->dev.platform_data && !pdev->dev.of_node) { + dev_err(&pdev->dev, "No platform data supplied\n"); + return -EINVAL; + } + dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_audio_dev), GFP_KERNEL); if (!dev) return -ENOMEM;
+ pdata = davinci_mcasp_set_pdata_from_of(pdev); + if (!pdata) { + dev_err(&pdev->dev, "no platform data\n"); + return -EINVAL; + } + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "no mem resource?\n"); @@ -888,7 +1010,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev) return -EBUSY; }
- pdata = pdev->dev.platform_data; pm_runtime_enable(&pdev->dev);
ret = pm_runtime_get_sync(&pdev->dev); @@ -986,6 +1107,7 @@ static struct platform_driver davinci_mcasp_driver = { .driver = { .name = "davinci-mcasp", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(mcasp_dt_ids), }, };
On Mon, Aug 27, 2012 at 06:56:42PM +0530, Hebbar, Gururaja wrote:
+- sram-size-playback : size of sram to be allocated during playback +- sram-size-capture : size of sram to be allocated during capture
These smell like runtime/policy configuration rather than fixed properties of the device so it probably shouldn't appear in the device tree, ideally at some point in the future we'll be able to work out some wonderful way of automatically allocating the resources.
That said if the rest of the series looks OK I'll apply this but it'd be nice to get these numbers from somewhere else.
Device tree support for tlv320aic3x CODEC driver
When the board boots with device tree, the driver will receive card, codec, dai interface details (like the card name, DAPM routing map, phandle for the audio components described in the dts file, codec mclk speed).
The card will be set up based on this information. Since the routing is provided via DT we can mark the card fully routed so core can take care of disconnecting the unused pins.
When here, code indentation and comment style is also fixed
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com --- Changes from V1: - Change DT parameter from "ti,codec-clock" to "ti,codec-clock-rate" - add more explanation to DT parameters
:000000 100644 0000000... fcbcd24... A Documentation/devicetree/bindings/sound/davinci-evm-audio.txt :100644 100644 ab0ad45... ca2a547... M sound/soc/davinci/davinci-evm.c .../bindings/sound/davinci-evm-audio.txt | 63 +++++++ sound/soc/davinci/davinci-evm.c | 185 +++++++++++++++++-- 2 files changed, 228 insertions(+), 20 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt new file mode 100644 index 0000000..fcbcd24 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt @@ -0,0 +1,63 @@ +* Texas Instruments SoC audio setups with TLV320AIC3X Codec + +Required properties: +- compatible : "ti,davinci-evm-audio" +- ti,model : The user-visible name of this sound complex. +- ti,audio-routing : A list of the connections between audio components. + Each entry is a pair of strings, the first being the connection's sink, + the second being the connection's source. Valid names for sources and + sinks are the codec's pins, and the jacks on the board: + + Codec pins: + + * MIC3L + * MIC3R + * LINE1L + * LINE2L + * LINE1R + * LINE2R + + Board connectors: + + * Headphone Jack + * Line Out + * Mic Jack + +- ti,mcasp-controller : The phandle of the McASP controller +- ti,audio-codec : The phandle of the TLV320AIC3x audio codec +- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec + +- dai-data : A list of DAI data used by SOC code to register + DAI, Codecs platform. + The string index "should" be as shown below. +dai-data = +"<DAI Name>", "<DAI Stream Name>", +"<CODEC DAI Name>", "<true if evm_aic3x_init is required, else false>", +"<evm ops required (evm_ops or evm_spdif_ops)>"; + +Here fields +"<DAI Name>" : used to indicate the DAI Name +"<DAI Stream Name>" : used to indicate the Stream Name +"<CODEC DAI Name>" : used to bind the link between Codec DAI and ASOC DAI + +Machine related options +"<true/false>" : Whether the machine specific initialization + : evm_aic3x_init() is required + +"<evm ops required>" : Which hardware ops function is to be used. + : (evm_ops or evm_spdif_ops) + + +Example: + +sound { + compatible = "ti,davinci-evm-audio"; + ti,model = "DA830 EVM"; + ti,audio-codec = <&tlv320aic3x>; + ti,mcasp-controller = <&mcasp1>; + ti,codec-clock-rate = <12000000>; + dai-data = + "TLV320AIC3X", "AIC3X", + "tlv320aic3x-hifi", "true", + "evm-ops"; +}; diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index ab0ad45..ca2a547 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -34,27 +34,38 @@ static int evm_hw_params(struct snd_pcm_substream *substream, struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_card *soc_card = codec->card; + struct device_node *np = soc_card->dev->of_node; int ret = 0; unsigned sysclk;
- /* ASP1 on DM355 EVM is clocked by an external oscillator */ - if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() || - machine_is_davinci_dm365_evm()) - sysclk = 27000000; - - /* ASP0 in DM6446 EVM is clocked by U55, as configured by - * board-dm644x-evm.c using GPIOs from U18. There are six - * options; here we "know" we use a 48 KHz sample rate. - */ - else if (machine_is_davinci_evm()) - sysclk = 12288000; - - else if (machine_is_davinci_da830_evm() || - machine_is_davinci_da850_evm()) - sysclk = 24576000; - - else - return -EINVAL; + if (np) { + ret = of_property_read_u32(np, "ti,codec-clock-rate", &sysclk); + if (ret < 0) + return ret; + } else { + /* ASP1 on DM355 EVM is clocked by an external oscillator */ + if (machine_is_davinci_dm355_evm() || + machine_is_davinci_dm6467_evm() || + machine_is_davinci_dm365_evm()) + sysclk = 27000000; + + /* + * ASP0 in DM6446 EVM is clocked by U55, as configured by + * board-dm644x-evm.c using GPIOs from U18. There are six + * options; here we "know" we use a 48 KHz sample rate. + */ + else if (machine_is_davinci_evm()) + sysclk = 12288000; + + else if (machine_is_davinci_da830_evm() || + machine_is_davinci_da850_evm()) + sysclk = 24576000; + + else + return -EINVAL; + }
/* set codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); @@ -127,13 +138,22 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; + struct device_node *np = codec->card->dev->of_node; + int ret;
/* Add davinci-evm specific widgets */ snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets, ARRAY_SIZE(aic3x_dapm_widgets));
- /* Set up davinci-evm specific audio path audio_map */ - snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); + if (np) { + ret = snd_soc_of_parse_audio_routing(codec->card, + "ti,audio-routing"); + if (ret) + return ret; + } else { + /* Set up davinci-evm specific audio path audio_map */ + snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); + }
/* not connected */ snd_soc_dapm_disable_pin(dapm, "MONO_LOUT"); @@ -282,6 +302,113 @@ static struct snd_soc_card da850_snd_soc_card = { .num_links = 1, };
+#if defined(CONFIG_OF) +/* + * This struct is just used as place holder. It will be filled with + * data from dt node + */ +static struct snd_soc_dai_link evm_dai = { +}; + +/* davinci evm audio machine driver */ +static struct snd_soc_card evm_soc_card = { + .owner = THIS_MODULE, + .dai_link = &evm_dai, + .num_links = 1, +}; + +static int davinci_evm_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + const char *stringPtr, *propname; + u32 val; + int ret = 0; + + propname = "dai-data"; + val = of_property_count_strings(np, propname); + if (val < 0) + return val; + + ret = of_property_read_string_index(np, propname, 0, &evm_dai.name); + if (ret < 0) + return ret; + + ret = of_property_read_string_index(np, propname, 1, + &evm_dai.stream_name); + if (ret < 0) + return ret; + + ret = of_property_read_string_index(np, propname, 2, + &evm_dai.codec_dai_name); + if (ret < 0) + return ret; + + ret = of_property_read_string_index(np, propname, 3, &stringPtr); + if (ret < 0) + return ret; + else + if (strcasecmp(stringPtr, "true") == 0) + evm_dai.init = evm_aic3x_init; + + ret = of_property_read_string_index(np, propname, 4, &stringPtr); + if (ret < 0) { + return ret; + } else { + if (strcasecmp(stringPtr, "evm-ops") == 0) + evm_dai.ops = &evm_ops; + else if (strcasecmp(stringPtr, "evm-spdif-ops") == 0) + evm_dai.ops = &evm_spdif_ops; + } + + evm_dai.codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0); + if (!evm_dai.codec_of_node) + return -EINVAL; + + evm_dai.cpu_dai_of_node = of_parse_phandle(np, + "ti,mcasp-controller", 0); + if (!evm_dai.cpu_dai_of_node) + return -EINVAL; + + evm_dai.platform_of_node = evm_dai.cpu_dai_of_node; + + evm_soc_card.dev = &pdev->dev; + ret = snd_soc_of_parse_card_name(&evm_soc_card, "ti,model"); + if (ret) + return ret; + + ret = snd_soc_register_card(&evm_soc_card); + if (ret) + dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); + + return ret; +} + +static int __devexit davinci_evm_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = platform_get_drvdata(pdev); + + snd_soc_unregister_card(card); + + return 0; +} + +static const struct of_device_id davinci_evm_dt_ids[] = { + { .compatible = "ti,davinci-evm-audio", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, davinci_mcasp_dt_ids); + +static struct platform_driver davinci_evm_driver = { + .probe = davinci_evm_probe, + .remove = __devexit_p(davinci_evm_remove), + .driver = { + .name = "davinci_evm", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(davinci_evm_dt_ids), + }, +}; +#endif + static struct platform_device *evm_snd_device;
static int __init evm_init(void) @@ -289,6 +416,14 @@ static int __init evm_init(void) struct snd_soc_card *evm_snd_dev_data; int index; int ret; +#if defined(CONFIG_OF) + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "ti,davinci-evm-audio"); + if (np) { + return platform_driver_register(&davinci_evm_driver); + } +#endif
if (machine_is_davinci_evm()) { evm_snd_dev_data = &dm6446_snd_soc_card_evm; @@ -325,6 +460,16 @@ static int __init evm_init(void)
static void __exit evm_exit(void) { +#if defined(CONFIG_OF) + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, "ti,davinci-evm-audio"); + if (np) { + platform_driver_unregister(&davinci_evm_driver); + return; + } +#endif + platform_device_unregister(evm_snd_device); }
On Mon, Aug 27, 2012 at 06:56:43PM +0530, Hebbar, Gururaja wrote:
Device tree support for tlv320aic3x CODEC driver
Not really for the CODEC - this is a machine driver.
+- dai-data : A list of DAI data used by SOC code to register
DAI, Codecs platform.
The string index "should" be as shown below.
+dai-data = +"<DAI Name>", "<DAI Stream Name>", +"<CODEC DAI Name>", "<true if evm_aic3x_init is required, else false>", +"<evm ops required (evm_ops or evm_spdif_ops)>";
What do these different ops do - how would the user figure it out or if they're needed at all?
On Mon, Aug 27, 2012 at 23:49:40, Mark Brown wrote:
On Mon, Aug 27, 2012 at 06:56:43PM +0530, Hebbar, Gururaja wrote:
Device tree support for tlv320aic3x CODEC driver
Not really for the CODEC - this is a machine driver.
+- dai-data : A list of DAI data used by SOC code to register
DAI, Codecs platform.
The string index "should" be as shown below.
+dai-data = +"<DAI Name>", "<DAI Stream Name>", +"<CODEC DAI Name>", "<true if evm_aic3x_init is required, else false>", +"<evm ops required (evm_ops or evm_spdif_ops)>";
What do these different ops do - how would the user figure it out or if they're needed at all?
Ok. I will correct and send.
Since other patches are accepted. I will send only this patch.
Regards, Gururaja
Device tree support for tlv320aic3x CODEC driver.
Signed-off-by: Hebbar, Gururaja gururaja.hebbar@ti.com --- Changes from V1: - use standard DT GPIO reference by phandle to populate gpio based DT parameters
:000000 100644 0000000... e7b98f4... A Documentation/devicetree/bindings/sound/tlv320aic3x.txt :100644 100644 01485bd... 5708a97... M sound/soc/codecs/tlv320aic3x.c .../devicetree/bindings/sound/tlv320aic3x.txt | 20 +++++++++++++ sound/soc/codecs/tlv320aic3x.c | 31 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt new file mode 100644 index 0000000..e7b98f4 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt @@ -0,0 +1,20 @@ +Texas Instruments - tlv320aic3x Codec module + +The tlv320aic3x serial control bus communicates through I2C protocols + +Required properties: +- compatible - "string" - "ti,tlv320aic3x" +- reg - <int> - I2C slave address + + +Optional properties: + +- gpio-reset - gpio pin number used for codec reset +- ai3x-gpio-func - <array of 2 int> - AIC3X_GPIO1 & AIC3X_GPIO2 Functionality + +Example: + +tlv320aic3x: tlv320aic3x@1b { + compatible = "ti,tlv320aic3x"; + reg = <0x1b>; +}; diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 01485bd..5708a97 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -40,6 +40,7 @@ #include <linux/i2c.h> #include <linux/gpio.h> #include <linux/regulator/consumer.h> +#include <linux/of_gpio.h> #include <linux/slab.h> #include <sound/core.h> #include <sound/pcm.h> @@ -1457,6 +1458,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, { struct aic3x_pdata *pdata = i2c->dev.platform_data; struct aic3x_priv *aic3x; + struct aic3x_setup_data *ai3x_setup; + struct device_node *np = i2c->dev.of_node; int ret;
aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); @@ -1471,6 +1474,25 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, if (pdata) { aic3x->gpio_reset = pdata->gpio_reset; aic3x->setup = pdata->setup; + } else if (np) { + ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup), + GFP_KERNEL); + if (ai3x_setup == NULL) { + dev_err(&i2c->dev, "failed to create private data\n"); + return -ENOMEM; + } + + ret = of_get_named_gpio(np, "gpio-reset", 0); + if (ret >= 0) + aic3x->gpio_reset = ret; + else + aic3x->gpio_reset = -1; + + if (of_property_read_u32_array(np, "ai3x-gpio-func", + ai3x_setup->gpio_func, 2) >= 0) { + aic3x->setup = ai3x_setup; + } + } else { aic3x->gpio_reset = -1; } @@ -1488,11 +1510,20 @@ static int aic3x_i2c_remove(struct i2c_client *client) return 0; }
+#if defined(CONFIG_OF) +static const struct of_device_id tlv320aic3x_of_match[] = { + { .compatible = "ti,tlv320aic3x", }, + {}, +}; +MODULE_DEVICE_TABLE(of, tlv320aic3x_of_match); +#endif + /* machine i2c codec control layer */ static struct i2c_driver aic3x_i2c_driver = { .driver = { .name = "tlv320aic3x-codec", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(tlv320aic3x_of_match), }, .probe = aic3x_i2c_probe, .remove = aic3x_i2c_remove,
participants (3)
-
Hebbar, Gururaja
-
Mark Brown
-
Sergey Vlasov