2 * ASoC driver for Lyrtech SFFSDR board.
4 * Author: Hugo Villeneuve
5 * Copyright (C) 2008 Lyrtech inc
7 * Based on ASoC driver for TI DAVINCI EVM platform, original copyright follow:
8 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
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.
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>
27 #include <asm/plat-sffsdr/sffsdr-fpga.h>
29 #include <mach/mcbsp.h>
30 #include <mach/edma.h>
32 #include "../codecs/pcm3008.h"
33 #include "davinci-pcm.h"
34 #include "davinci-i2s.h"
36 static int sffsdr_hw_params(struct snd_pcm_substream
*substream
,
37 struct snd_pcm_hw_params
*params
,
38 struct snd_soc_dai
*dai
)
40 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
41 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
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
);
55 /* Fsref can be 32000, 44100 or 48000. */
56 fs
= params_rate(params
);
58 pr_debug("sffsdr_hw_params: rate = %d Hz\n", fs
);
60 return sffsdr_fpga_set_codec_fs(fs
);
63 static struct snd_soc_ops sffsdr_ops
= {
64 .hw_params
= sffsdr_hw_params
,
67 /* davinci-sffsdr digital audio interface glue - connects codec <--> CPU */
68 static 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
,
76 /* davinci-sffsdr audio machine driver */
77 static struct snd_soc_card snd_soc_sffsdr
= {
78 .name
= "DaVinci SFFSDR",
79 .dai_link
= &sffsdr_dai
,
83 /* sffsdr audio private data */
84 static struct pcm3008_setup_data sffsdr_pcm3008_setup
= {
91 /* sffsdr audio subsystem */
92 static struct snd_soc_device sffsdr_snd_devdata
= {
93 .card
= &snd_soc_sffsdr
,
94 .platform
= &davinci_soc_platform
,
95 .codec_dev
= &soc_codec_dev_pcm3008
,
96 .codec_data
= &sffsdr_pcm3008_setup
,
99 static struct resource sffsdr_snd_resources
[] = {
101 .start
= DAVINCI_MCBSP_BASE
,
102 .end
= DAVINCI_MCBSP_BASE
+ SZ_8K
- 1,
103 .flags
= IORESOURCE_MEM
,
107 static struct evm_snd_platform_data sffsdr_snd_data
= {
108 .tx_dma_ch
= DAVINCI_DMA_MCBSP_TX
,
109 .rx_dma_ch
= DAVINCI_DMA_MCBSP_RX
,
112 static struct platform_device
*sffsdr_snd_device
;
114 static int __init
sffsdr_init(void)
118 sffsdr_snd_device
= platform_device_alloc("soc-audio", 0);
119 if (!sffsdr_snd_device
) {
120 printk(KERN_ERR
"platform device allocation failed\n");
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
;
128 ret
= platform_device_add_resources(sffsdr_snd_device
,
129 sffsdr_snd_resources
,
130 ARRAY_SIZE(sffsdr_snd_resources
));
132 printk(KERN_ERR
"platform device add ressources failed\n");
136 ret
= platform_device_add(sffsdr_snd_device
);
143 platform_device_put(sffsdr_snd_device
);
147 static void __exit
sffsdr_exit(void)
149 platform_device_unregister(sffsdr_snd_device
);
152 module_init(sffsdr_init
);
153 module_exit(sffsdr_exit
);
155 MODULE_AUTHOR("Hugo Villeneuve");
156 MODULE_DESCRIPTION("Lyrtech SFFSDR ASoC driver");
157 MODULE_LICENSE("GPL");