aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Villeneuve <hugo@hugovil.com>2008-11-19 01:37:32 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2008-11-19 08:18:42 -0500
commit08bd16869645f435eba6a612d166532b3047c5f7 (patch)
treeb89001a9bf495633e00c211f7f988d289e69066c
parent1c0090c280da18f79e3e94168b5f3bfe4eb5f1c8 (diff)
ASoC: Add driver for the Lyrtech SFFSDR board
The PCM3008 is used on the Lyrtech SFFSDR board, in conjunction with an FPGA that generates the bit clock and the master clock [Downgraded the rate debug print to pr_debug() in hw_params, converted asm/gpio.h to linux/gpio.h -- broonie] Signed-off-by: Hugo Villeneuve <hugo@hugovil.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/davinci/Kconfig10
-rw-r--r--sound/soc/davinci/Makefile2
-rw-r--r--sound/soc/davinci/davinci-sffsdr.c156
3 files changed, 168 insertions, 0 deletions
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
index 8f7e33834902..b502741692d6 100644
--- a/sound/soc/davinci/Kconfig
+++ b/sound/soc/davinci/Kconfig
@@ -17,3 +17,13 @@ config SND_DAVINCI_SOC_EVM
17 help 17 help
18 Say Y if you want to add support for SoC audio on TI 18 Say Y if you want to add support for SoC audio on TI
19 DaVinci EVM platform. 19 DaVinci EVM platform.
20
21config SND_DAVINCI_SOC_SFFSDR
22 tristate "SoC Audio support for SFFSDR"
23 depends on SND_DAVINCI_SOC && MACH_DAVINCI_SFFSDR
24 select SND_DAVINCI_SOC_I2S
25 select SND_SOC_PCM3008
26 select SFFSDR_FPGA
27 help
28 Say Y if you want to add support for SoC audio on
29 Lyrtech SFFSDR board.
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile
index ca772e5b4637..ca8bae1fc3f6 100644
--- a/sound/soc/davinci/Makefile
+++ b/sound/soc/davinci/Makefile
@@ -7,5 +7,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o
7 7
8# DAVINCI Machine Support 8# DAVINCI Machine Support
9snd-soc-evm-objs := davinci-evm.o 9snd-soc-evm-objs := davinci-evm.o
10snd-soc-sffsdr-objs := davinci-sffsdr.o
10 11
11obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o 12obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
13obj-$(CONFIG_SND_DAVINCI_SOC_SFFSDR) += snd-soc-sffsdr.o
diff --git a/sound/soc/davinci/davinci-sffsdr.c b/sound/soc/davinci/davinci-sffsdr.c
new file mode 100644
index 000000000000..69a8a769f4d8
--- /dev/null
+++ b/sound/soc/davinci/davinci-sffsdr.c
@@ -0,0 +1,156 @@
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{
39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
40 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
41 int fs;
42 int ret = 0;
43
44 /* Set cpu DAI configuration:
45 * CLKX and CLKR are the inputs for the Sample Rate Generator.
46 * FSX and FSR are outputs, driven by the sample Rate Generator. */
47 ret = snd_soc_dai_set_fmt(cpu_dai,
48 SND_SOC_DAIFMT_RIGHT_J |
49 SND_SOC_DAIFMT_CBM_CFS |
50 SND_SOC_DAIFMT_IB_NF);
51 if (ret < 0)
52 return ret;
53
54 /* Fsref can be 32000, 44100 or 48000. */
55 fs = params_rate(params);
56
57 pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs);
58
59 return sffsdr_fpga_set_codec_fs(fs);
60}
61
62static struct snd_soc_ops sffsdr_ops = {
63 .hw_params = sffsdr_hw_params,
64};
65
66/* davinci-sffsdr digital audio interface glue - connects codec <--> CPU */
67static struct snd_soc_dai_link sffsdr_dai = {
68 .name = "PCM3008", /* Codec name */
69 .stream_name = "PCM3008 HiFi",
70 .cpu_dai = &davinci_i2s_dai,
71 .codec_dai = &pcm3008_dai,
72 .ops = &sffsdr_ops,
73};
74
75/* davinci-sffsdr audio machine driver */
76static struct snd_soc_machine snd_soc_machine_sffsdr = {
77 .name = "DaVinci SFFSDR",
78 .dai_link = &sffsdr_dai,
79 .num_links = 1,
80};
81
82/* sffsdr audio private data */
83static struct pcm3008_setup_data sffsdr_pcm3008_setup = {
84 .dem0_pin = GPIO(45),
85 .dem1_pin = GPIO(46),
86 .pdad_pin = GPIO(47),
87 .pdda_pin = GPIO(38),
88};
89
90/* sffsdr audio subsystem */
91static struct snd_soc_device sffsdr_snd_devdata = {
92 .machine = &snd_soc_machine_sffsdr,
93 .platform = &davinci_soc_platform,
94 .codec_dev = &soc_codec_dev_pcm3008,
95 .codec_data = &sffsdr_pcm3008_setup,
96};
97
98static struct resource sffsdr_snd_resources[] = {
99 {
100 .start = DAVINCI_MCBSP_BASE,
101 .end = DAVINCI_MCBSP_BASE + SZ_8K - 1,
102 .flags = IORESOURCE_MEM,
103 },
104};
105
106static struct evm_snd_platform_data sffsdr_snd_data = {
107 .tx_dma_ch = DAVINCI_DMA_MCBSP_TX,
108 .rx_dma_ch = DAVINCI_DMA_MCBSP_RX,
109};
110
111static struct platform_device *sffsdr_snd_device;
112
113static int __init sffsdr_init(void)
114{
115 int ret;
116
117 sffsdr_snd_device = platform_device_alloc("soc-audio", 0);
118 if (!sffsdr_snd_device) {
119 printk(KERN_ERR "platform device allocation failed\n");
120 return -ENOMEM;
121 }
122
123 platform_set_drvdata(sffsdr_snd_device, &sffsdr_snd_devdata);
124 sffsdr_snd_devdata.dev = &sffsdr_snd_device->dev;
125 sffsdr_snd_device->dev.platform_data = &sffsdr_snd_data;
126
127 ret = platform_device_add_resources(sffsdr_snd_device,
128 sffsdr_snd_resources,
129 ARRAY_SIZE(sffsdr_snd_resources));
130 if (ret) {
131 printk(KERN_ERR "platform device add ressources failed\n");
132 goto error;
133 }
134
135 ret = platform_device_add(sffsdr_snd_device);
136 if (ret)
137 goto error;
138
139 return ret;
140
141error:
142 platform_device_put(sffsdr_snd_device);
143 return ret;
144}
145
146static void __exit sffsdr_exit(void)
147{
148 platform_device_unregister(sffsdr_snd_device);
149}
150
151module_init(sffsdr_init);
152module_exit(sffsdr_exit);
153
154MODULE_AUTHOR("Hugo Villeneuve");
155MODULE_DESCRIPTION("Lyrtech SFFSDR ASoC driver");
156MODULE_LICENSE("GPL");