aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci/davinci-sffsdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/davinci/davinci-sffsdr.c')
-rw-r--r--sound/soc/davinci/davinci-sffsdr.c157
1 files changed, 157 insertions, 0 deletions
diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c
new file mode 100644
index 000000000000..f67579d52765
--- /dev/null
+++ b/sound/soc/davinci/davinci-sffsdr.c
@@ -0,0 +1,157 @@
1/*
2 * ASoC driver for Lyrtech SFFSDR board.
3 *
4 * Author: Hugo Villeneuve
5 * Copyright (C) 2008 Lyrtech inc
6 *
7 * Based on ASoC driver for TI DAVINCI EVM platform, original copyright follow:
8 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/timer.h>
18#include <linux/interrupt.h>
19#include <linux/platform_device.h>
20#include <linux/gpio.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/soc.h>
24#include <sound/soc-dapm.h>
25
26#include <asm/dma.h>
27#include <asm/plat-sffsdr/sffsdr-fpga.h>
28
29#include <mach/mcbsp.h>
30#include <mach/edma.h>
31
32#include "../codecs/pcm3008.h"
33#include "davinci-pcm.h"
34#include "davinci-i2s.h"
35
36static int sffsdr_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params,
38 struct snd_soc_dai *dai)
39{
40 struct snd_soc_pcm_runtime *rtd = substream->private_data;
41 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
42 int fs;
43 int ret = 0;
44
45 /* Set cpu DAI configuration:
46 * CLKX and CLKR are the inputs for the Sample Rate Generator.
47 * FSX and FSR are outputs, driven by the sample Rate Generator. */
48 ret = snd_soc_dai_set_fmt(cpu_dai,
49 SND_SOC_DAIFMT_RIGHT_J |
50 SND_SOC_DAIFMT_CBM_CFS |
51 SND_SOC_DAIFMT_IB_NF);
52 if (ret < 0)
53 return ret;
54
55 /* Fsref can be 32000, 44100 or 48000. */
56 fs = params_rate(params);
57
58 pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs);
59
60 return sffsdr_fpga_set_codec_fs(fs);
61}
62
63static struct snd_soc_ops sffsdr_ops = {
64 .hw_params = sffsdr_hw_params,
65};
66
67/* davinci-sffsdr digital audio interface glue - connects codec <--> CPU */
68static struct snd_soc_dai_link sffsdr_dai = {
69 .name = "PCM3008", /* Codec name */
70 .stream_name = "PCM3008 HiFi",
71 .cpu_dai = &davinci_i2s_dai,
72 .codec_dai = &pcm3008_dai,
73 .ops = &sffsdr_ops,
74};
75
76/* davinci-sffsdr audio machine driver */
77static struct snd_soc_card snd_soc_sffsdr = {
78 .name = "DaVinci SFFSDR",
79 .platform = &davinci_soc_platform,
80 .dai_link = &sffsdr_dai,
81 .num_links = 1,
82};
83
84/* sffsdr audio private data */
85static struct pcm3008_setup_data sffsdr_pcm3008_setup = {
86 .dem0_pin = GPIO(45),
87 .dem1_pin = GPIO(46),
88 .pdad_pin = GPIO(47),
89 .pdda_pin = GPIO(38),
90};
91
92/* sffsdr audio subsystem */
93static struct snd_soc_device sffsdr_snd_devdata = {
94 .card = &snd_soc_sffsdr,
95 .codec_dev = &soc_codec_dev_pcm3008,
96 .codec_data = &sffsdr_pcm3008_setup,
97};
98
99static struct resource sffsdr_snd_resources[] = {
100 {
101 .start = DAVINCI_MCBSP_BASE,
102 .end = DAVINCI_MCBSP_BASE + SZ_8K - 1,
103 .flags = IORESOURCE_MEM,
104 },
105};
106
107static struct evm_snd_platform_data sffsdr_snd_data = {
108 .tx_dma_ch = DAVINCI_DMA_MCBSP_TX,
109 .rx_dma_ch = DAVINCI_DMA_MCBSP_RX,
110};
111
112static struct platform_device *sffsdr_snd_device;
113
114static int __init sffsdr_init(void)
115{
116 int ret;
117
118 sffsdr_snd_device = platform_device_alloc("soc-audio", 0);
119 if (!sffsdr_snd_device) {
120 printk(KERN_ERR "platform device allocation failed\n");
121 return -ENOMEM;
122 }
123
124 platform_set_drvdata(sffsdr_snd_device, &sffsdr_snd_devdata);
125 sffsdr_snd_devdata.dev = &sffsdr_snd_device->dev;
126 sffsdr_snd_device->dev.platform_data = &sffsdr_snd_data;
127
128 ret = platform_device_add_resources(sffsdr_snd_device,
129 sffsdr_snd_resources,
130 ARRAY_SIZE(sffsdr_snd_resources));
131 if (ret) {
132 printk(KERN_ERR "platform device add ressources failed\n");
133 goto error;
134 }
135
136 ret = platform_device_add(sffsdr_snd_device);
137 if (ret)
138 goto error;
139
140 return ret;
141
142error:
143 platform_device_put(sffsdr_snd_device);
144 return ret;
145}
146
147static void __exit sffsdr_exit(void)
148{
149 platform_device_unregister(sffsdr_snd_device);
150}
151
152module_init(sffsdr_init);
153module_exit(sffsdr_exit);
154
155MODULE_AUTHOR("Hugo Villeneuve");
156MODULE_DESCRIPTION("Lyrtech SFFSDR ASoC driver");
157MODULE_LICENSE("GPL");