Commit | Line | Data |
---|---|---|
14610ce7 AA |
1 | /* |
2 | * omap3evm.c -- ALSA SoC support for OMAP3 EVM | |
3 | * | |
4 | * Author: Anuj Aggarwal <anuj.aggarwal@ti.com> | |
5 | * | |
6 | * Based on sound/soc/omap/beagle.c by Steve Sakoman | |
7 | * | |
8 | * Copyright (C) 2008 Texas Instruments, Incorporated | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify it | |
11 | * under the terms of the GNU General Public License as published by the | |
12 | * Free Software Foundation version 2. | |
13 | * | |
14 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, | |
15 | * whether express or implied; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | */ | |
19 | ||
20 | #include <linux/clk.h> | |
21 | #include <linux/platform_device.h> | |
da155d5b | 22 | #include <linux/module.h> |
14610ce7 AA |
23 | #include <sound/core.h> |
24 | #include <sound/pcm.h> | |
25 | #include <sound/soc.h> | |
14610ce7 AA |
26 | |
27 | #include <asm/mach-types.h> | |
28 | #include <mach/hardware.h> | |
29 | #include <mach/gpio.h> | |
2203747c | 30 | #include <linux/platform_data/asoc-ti-mcbsp.h> |
14610ce7 AA |
31 | |
32 | #include "omap-mcbsp.h" | |
33 | #include "omap-pcm.h" | |
14610ce7 AA |
34 | |
35 | static int omap3evm_hw_params(struct snd_pcm_substream *substream, | |
36 | struct snd_pcm_hw_params *params) | |
37 | { | |
38 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
f0fba2ad | 39 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
14610ce7 AA |
40 | int ret; |
41 | ||
14610ce7 AA |
42 | /* Set the codec system clock for DAC and ADC */ |
43 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000, | |
44 | SND_SOC_CLOCK_IN); | |
45 | if (ret < 0) { | |
46 | printk(KERN_ERR "Can't set codec system clock\n"); | |
47 | return ret; | |
48 | } | |
49 | ||
50 | return 0; | |
51 | } | |
52 | ||
53 | static struct snd_soc_ops omap3evm_ops = { | |
54 | .hw_params = omap3evm_hw_params, | |
55 | }; | |
56 | ||
57 | /* Digital audio interface glue - connects codec <--> CPU */ | |
58 | static struct snd_soc_dai_link omap3evm_dai = { | |
59 | .name = "TWL4030", | |
60 | .stream_name = "TWL4030", | |
45656b44 | 61 | .cpu_dai_name = "omap-mcbsp.2", |
f0fba2ad LG |
62 | .codec_dai_name = "twl4030-hifi", |
63 | .platform_name = "omap-pcm-audio", | |
64 | .codec_name = "twl4030-codec", | |
cf9feff2 JN |
65 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
66 | SND_SOC_DAIFMT_CBM_CFM, | |
14610ce7 AA |
67 | .ops = &omap3evm_ops, |
68 | }; | |
69 | ||
70 | /* Audio machine driver */ | |
71 | static struct snd_soc_card snd_soc_omap3evm = { | |
72 | .name = "omap3evm", | |
b425b884 | 73 | .owner = THIS_MODULE, |
14610ce7 AA |
74 | .dai_link = &omap3evm_dai, |
75 | .num_links = 1, | |
76 | }; | |
77 | ||
14610ce7 AA |
78 | static struct platform_device *omap3evm_snd_device; |
79 | ||
80 | static int __init omap3evm_soc_init(void) | |
81 | { | |
82 | int ret; | |
83 | ||
ec588ae6 | 84 | if (!machine_is_omap3evm()) |
14610ce7 | 85 | return -ENODEV; |
14610ce7 AA |
86 | pr_info("OMAP3 EVM SoC init\n"); |
87 | ||
88 | omap3evm_snd_device = platform_device_alloc("soc-audio", -1); | |
89 | if (!omap3evm_snd_device) { | |
90 | printk(KERN_ERR "Platform device allocation failed\n"); | |
91 | return -ENOMEM; | |
92 | } | |
93 | ||
f0fba2ad | 94 | platform_set_drvdata(omap3evm_snd_device, &snd_soc_omap3evm); |
14610ce7 AA |
95 | ret = platform_device_add(omap3evm_snd_device); |
96 | if (ret) | |
97 | goto err1; | |
98 | ||
99 | return 0; | |
100 | ||
101 | err1: | |
102 | printk(KERN_ERR "Unable to add platform device\n"); | |
103 | platform_device_put(omap3evm_snd_device); | |
104 | ||
105 | return ret; | |
106 | } | |
107 | ||
108 | static void __exit omap3evm_soc_exit(void) | |
109 | { | |
110 | platform_device_unregister(omap3evm_snd_device); | |
111 | } | |
112 | ||
113 | module_init(omap3evm_soc_init); | |
114 | module_exit(omap3evm_soc_exit); | |
115 | ||
116 | MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>"); | |
117 | MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM"); | |
bd6ddcb4 | 118 | MODULE_LICENSE("GPL v2"); |