Commit | Line | Data |
---|---|---|
89e9abe7 AA |
1 | /* |
2 | * am3517evm.c -- ALSA SoC support for OMAP3517 / AM3517 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) 2009 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> |
89e9abe7 AA |
23 | #include <sound/core.h> |
24 | #include <sound/pcm.h> | |
25 | #include <sound/soc.h> | |
89e9abe7 AA |
26 | |
27 | #include <asm/mach-types.h> | |
2203747c | 28 | #include <linux/platform_data/asoc-ti-mcbsp.h> |
89e9abe7 AA |
29 | |
30 | #include "omap-mcbsp.h" | |
31 | #include "omap-pcm.h" | |
32 | ||
33 | #include "../codecs/tlv320aic23.h" | |
34 | ||
35 | #define CODEC_CLOCK 12000000 | |
36 | ||
37 | static int am3517evm_hw_params(struct snd_pcm_substream *substream, | |
38 | struct snd_pcm_hw_params *params) | |
39 | { | |
40 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
f0fba2ad | 41 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
89e9abe7 AA |
42 | int ret; |
43 | ||
89e9abe7 AA |
44 | /* Set the codec system clock for DAC and ADC */ |
45 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, | |
46 | CODEC_CLOCK, SND_SOC_CLOCK_IN); | |
fca04aea | 47 | if (ret < 0) |
89e9abe7 | 48 | printk(KERN_ERR "can't set codec system clock\n"); |
89e9abe7 | 49 | |
fca04aea | 50 | return ret; |
89e9abe7 AA |
51 | } |
52 | ||
53 | static struct snd_soc_ops am3517evm_ops = { | |
54 | .hw_params = am3517evm_hw_params, | |
55 | }; | |
56 | ||
57 | /* am3517evm machine dapm widgets */ | |
58 | static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = { | |
59 | SND_SOC_DAPM_HP("Line Out", NULL), | |
60 | SND_SOC_DAPM_LINE("Line In", NULL), | |
61 | SND_SOC_DAPM_MIC("Mic In", NULL), | |
62 | }; | |
63 | ||
64 | static const struct snd_soc_dapm_route audio_map[] = { | |
65 | /* Line Out connected to LLOUT, RLOUT */ | |
66 | {"Line Out", NULL, "LOUT"}, | |
67 | {"Line Out", NULL, "ROUT"}, | |
68 | ||
69 | {"LLINEIN", NULL, "Line In"}, | |
70 | {"RLINEIN", NULL, "Line In"}, | |
71 | ||
72 | {"MICIN", NULL, "Mic In"}, | |
73 | }; | |
74 | ||
89e9abe7 AA |
75 | /* Digital audio interface glue - connects codec <--> CPU */ |
76 | static struct snd_soc_dai_link am3517evm_dai = { | |
77 | .name = "TLV320AIC23", | |
78 | .stream_name = "AIC23", | |
45656b44 | 79 | .cpu_dai_name = "omap-mcbsp.1", |
f0fba2ad LG |
80 | .codec_dai_name = "tlv320aic23-hifi", |
81 | .platform_name = "omap-pcm-audio", | |
ffd6eae2 | 82 | .codec_name = "tlv320aic23-codec.2-001a", |
cf9feff2 JN |
83 | .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_NB_NF | |
84 | SND_SOC_DAIFMT_CBM_CFM, | |
89e9abe7 AA |
85 | .ops = &am3517evm_ops, |
86 | }; | |
87 | ||
88 | /* Audio machine driver */ | |
89 | static struct snd_soc_card snd_soc_am3517evm = { | |
90 | .name = "am3517evm", | |
b425b884 | 91 | .owner = THIS_MODULE, |
89e9abe7 AA |
92 | .dai_link = &am3517evm_dai, |
93 | .num_links = 1, | |
d2266025 PU |
94 | |
95 | .dapm_widgets = tlv320aic23_dapm_widgets, | |
96 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), | |
97 | .dapm_routes = audio_map, | |
98 | .num_dapm_routes = ARRAY_SIZE(audio_map), | |
89e9abe7 AA |
99 | }; |
100 | ||
89e9abe7 AA |
101 | static struct platform_device *am3517evm_snd_device; |
102 | ||
103 | static int __init am3517evm_soc_init(void) | |
104 | { | |
105 | int ret; | |
106 | ||
ec588ae6 | 107 | if (!machine_is_omap3517evm()) |
89e9abe7 | 108 | return -ENODEV; |
89e9abe7 AA |
109 | pr_info("OMAP3517 / AM3517 EVM SoC init\n"); |
110 | ||
111 | am3517evm_snd_device = platform_device_alloc("soc-audio", -1); | |
112 | if (!am3517evm_snd_device) { | |
113 | printk(KERN_ERR "Platform device allocation failed\n"); | |
114 | return -ENOMEM; | |
115 | } | |
116 | ||
f0fba2ad | 117 | platform_set_drvdata(am3517evm_snd_device, &snd_soc_am3517evm); |
89e9abe7 AA |
118 | |
119 | ret = platform_device_add(am3517evm_snd_device); | |
120 | if (ret) | |
121 | goto err1; | |
122 | ||
123 | return 0; | |
124 | ||
125 | err1: | |
126 | printk(KERN_ERR "Unable to add platform device\n"); | |
127 | platform_device_put(am3517evm_snd_device); | |
128 | ||
129 | return ret; | |
130 | } | |
131 | ||
132 | static void __exit am3517evm_soc_exit(void) | |
133 | { | |
134 | platform_device_unregister(am3517evm_snd_device); | |
135 | } | |
136 | ||
137 | module_init(am3517evm_soc_init); | |
138 | module_exit(am3517evm_soc_exit); | |
139 | ||
140 | MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>"); | |
141 | MODULE_DESCRIPTION("ALSA SoC OMAP3517 / AM3517 EVM"); | |
142 | MODULE_LICENSE("GPL v2"); |